2016-01-15 14:57:40 +01:00
|
|
|
/****************************************************************************
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 BlackBerry Limited. All rights reserved.
|
2012-06-29 07:23:13 +02:00
|
|
|
** Contact: KDAB (info@kdab.com)
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2012-10-02 09:12:39 +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.
|
2012-06-29 07:23:13 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
#include "qnxdevice.h"
|
2019-02-20 19:13:28 +01:00
|
|
|
|
|
|
|
|
#include "qnxconstants.h"
|
2013-05-30 13:53:28 +02:00
|
|
|
#include "qnxdevicetester.h"
|
2013-09-27 16:55:38 +02:00
|
|
|
#include "qnxdeviceprocesslist.h"
|
2013-09-16 15:30:30 +02:00
|
|
|
#include "qnxdeviceprocesssignaloperation.h"
|
2014-05-27 12:46:24 +02:00
|
|
|
#include "qnxdeployqtlibrariesdialog.h"
|
2015-11-09 14:20:46 +02:00
|
|
|
#include "qnxdeviceprocess.h"
|
2019-02-20 19:13:28 +01:00
|
|
|
#include "qnxdevicewizard.h"
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-10-21 14:54:49 +02:00
|
|
|
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
|
2019-03-13 08:06:08 +01:00
|
|
|
#include <projectexplorer/runcontrol.h>
|
2018-05-16 15:42:03 +02:00
|
|
|
|
2013-09-16 15:30:30 +02:00
|
|
|
#include <ssh/sshconnection.h>
|
2016-04-19 16:43:30 +02:00
|
|
|
#include <utils/port.h>
|
2013-10-21 14:54:49 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2017-09-28 18:46:16 +02:00
|
|
|
#include <utils/stringutils.h>
|
2013-04-29 15:45:00 +02:00
|
|
|
|
2013-10-21 14:54:49 +02:00
|
|
|
#include <QApplication>
|
2020-06-19 13:46:26 +02:00
|
|
|
#include <QRegularExpression>
|
2013-04-29 15:45:00 +02:00
|
|
|
#include <QStringList>
|
2013-10-21 14:54:49 +02:00
|
|
|
#include <QThread>
|
2013-04-29 15:45:00 +02:00
|
|
|
|
2014-11-27 17:46:45 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace Qnx {
|
2019-02-20 19:13:28 +01:00
|
|
|
namespace Internal {
|
2012-06-29 07:23:13 +02:00
|
|
|
|
2013-10-21 14:54:49 +02:00
|
|
|
const char QnxVersionKey[] = "QnxVersion";
|
2014-11-27 17:46:45 +01:00
|
|
|
|
2015-02-03 23:51:12 +02:00
|
|
|
class QnxPortsGatheringMethod : public PortsGatheringMethod
|
2012-08-01 16:26:27 +02:00
|
|
|
{
|
|
|
|
|
// TODO: The command is probably needlessly complicated because the parsing method
|
|
|
|
|
// used to be fixed. These two can now be matched to each other.
|
2017-08-07 18:54:01 +02:00
|
|
|
Runnable runnable(QAbstractSocket::NetworkLayerProtocol protocol) const override
|
2012-08-01 16:26:27 +02:00
|
|
|
{
|
2019-07-23 10:58:00 +02:00
|
|
|
Q_UNUSED(protocol)
|
2018-05-16 15:42:03 +02:00
|
|
|
Runnable runnable;
|
2021-08-10 09:19:30 +02:00
|
|
|
runnable.command = {"netstat", {"-na"}};
|
2017-08-07 18:54:01 +02:00
|
|
|
return runnable;
|
2012-08-01 16:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-07 18:54:01 +02:00
|
|
|
QList<Port> usedPorts(const QByteArray &output) const override
|
2012-08-01 16:26:27 +02:00
|
|
|
{
|
2017-09-28 18:46:16 +02:00
|
|
|
QList<Utils::Port> ports;
|
|
|
|
|
const QList<QByteArray> lines = output.split('\n');
|
|
|
|
|
for (const QByteArray &line : lines) {
|
|
|
|
|
const Port port(Utils::parseUsedPortFromNetstatOutput(line));
|
|
|
|
|
if (port.isValid() && !ports.contains(port))
|
|
|
|
|
ports.append(port);
|
2012-08-01 16:26:27 +02:00
|
|
|
}
|
|
|
|
|
return ports;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
QnxDevice::QnxDevice()
|
2019-01-11 14:50:08 +01:00
|
|
|
{
|
2019-06-19 13:28:14 +02:00
|
|
|
setDisplayType(tr("QNX"));
|
2019-08-01 14:30:10 +02:00
|
|
|
setDefaultDisplayName(tr("QNX Device"));
|
2019-08-16 10:17:45 +02:00
|
|
|
setOsType(OsTypeOtherUnix);
|
|
|
|
|
|
2019-01-11 14:50:08 +01:00
|
|
|
addDeviceAction({tr("Deploy Qt libraries..."), [](const IDevice::Ptr &device, QWidget *parent) {
|
|
|
|
|
QnxDeployQtLibrariesDialog dialog(device, parent);
|
|
|
|
|
dialog.exec();
|
|
|
|
|
}});
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
int QnxDevice::qnxVersion() const
|
2013-10-21 14:54:49 +02:00
|
|
|
{
|
|
|
|
|
if (m_versionNumber == 0)
|
|
|
|
|
updateVersionNumber();
|
|
|
|
|
|
|
|
|
|
return m_versionNumber;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
void QnxDevice::updateVersionNumber() const
|
2013-10-21 14:54:49 +02:00
|
|
|
{
|
|
|
|
|
QEventLoop eventLoop;
|
2015-02-03 23:51:12 +02:00
|
|
|
SshDeviceProcess versionNumberProcess(sharedFromThis());
|
2016-03-15 09:26:34 +01:00
|
|
|
QObject::connect(&versionNumberProcess, &SshDeviceProcess::finished, &eventLoop, &QEventLoop::quit);
|
|
|
|
|
QObject::connect(&versionNumberProcess, &DeviceProcess::error, &eventLoop, &QEventLoop::quit);
|
2013-10-21 14:54:49 +02:00
|
|
|
|
2018-05-16 15:42:03 +02:00
|
|
|
Runnable r;
|
2021-08-10 09:19:30 +02:00
|
|
|
r.command = {"uname", {"-r"}};
|
2016-01-27 18:25:13 +01:00
|
|
|
versionNumberProcess.start(r);
|
2013-10-21 14:54:49 +02:00
|
|
|
|
|
|
|
|
bool isGuiThread = QThread::currentThread() == QCoreApplication::instance()->thread();
|
|
|
|
|
if (isGuiThread)
|
|
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
|
|
|
|
|
|
|
|
eventLoop.exec(QEventLoop::ExcludeUserInputEvents);
|
|
|
|
|
|
|
|
|
|
QByteArray output = versionNumberProcess.readAllStandardOutput();
|
|
|
|
|
QString versionMessage = QString::fromLatin1(output);
|
2020-06-19 13:46:26 +02:00
|
|
|
const QRegularExpression versionNumberRegExp("(\\d+)\\.(\\d+)\\.(\\d+)");
|
|
|
|
|
const QRegularExpressionMatch match = versionNumberRegExp.match(versionMessage);
|
|
|
|
|
if (match.hasMatch()) {
|
|
|
|
|
int major = match.captured(1).toInt();
|
|
|
|
|
int minor = match.captured(2).toInt();
|
|
|
|
|
int patch = match.captured(3).toInt();
|
2013-10-21 14:54:49 +02:00
|
|
|
m_versionNumber = (major << 16)|(minor<<8)|(patch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isGuiThread)
|
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
void QnxDevice::fromMap(const QVariantMap &map)
|
2013-10-21 14:54:49 +02:00
|
|
|
{
|
|
|
|
|
m_versionNumber = map.value(QLatin1String(QnxVersionKey), 0).toInt();
|
|
|
|
|
RemoteLinux::LinuxDevice::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
QVariantMap QnxDevice::toMap() const
|
2013-10-21 14:54:49 +02:00
|
|
|
{
|
|
|
|
|
QVariantMap map(RemoteLinux::LinuxDevice::toMap());
|
|
|
|
|
map.insert(QLatin1String(QnxVersionKey), m_versionNumber);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
PortsGatheringMethod::Ptr QnxDevice::portsGatheringMethod() const
|
2012-08-01 16:26:27 +02:00
|
|
|
{
|
2015-02-03 23:51:12 +02:00
|
|
|
return PortsGatheringMethod::Ptr(new QnxPortsGatheringMethod);
|
2012-08-01 16:26:27 +02:00
|
|
|
}
|
2013-04-29 15:45:00 +02:00
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
DeviceProcessList *QnxDevice::createProcessListModel(QObject *parent) const
|
2013-04-29 15:45:00 +02:00
|
|
|
{
|
|
|
|
|
return new QnxDeviceProcessList(sharedFromThis(), parent);
|
|
|
|
|
}
|
2013-05-30 13:53:28 +02:00
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
DeviceTester *QnxDevice::createDeviceTester() const
|
2013-05-30 13:53:28 +02:00
|
|
|
{
|
|
|
|
|
return new QnxDeviceTester;
|
|
|
|
|
}
|
2013-09-16 15:30:30 +02:00
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
DeviceProcess *QnxDevice::createProcess(QObject *parent) const
|
2014-11-27 17:46:45 +01:00
|
|
|
{
|
|
|
|
|
return new QnxDeviceProcess(sharedFromThis(), parent);
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 08:56:05 +02:00
|
|
|
DeviceProcessSignalOperation::Ptr QnxDevice::signalOperation() const
|
2013-09-16 15:30:30 +02:00
|
|
|
{
|
2015-02-03 23:51:12 +02:00
|
|
|
return DeviceProcessSignalOperation::Ptr(
|
2013-09-16 15:30:30 +02:00
|
|
|
new QnxDeviceProcessSignalOperation(sshParameters()));
|
|
|
|
|
}
|
2014-11-27 17:46:45 +01:00
|
|
|
|
2019-02-20 19:13:28 +01:00
|
|
|
// Factory
|
|
|
|
|
|
|
|
|
|
QnxDeviceFactory::QnxDeviceFactory()
|
|
|
|
|
: ProjectExplorer::IDeviceFactory(Constants::QNX_QNX_OS_TYPE)
|
|
|
|
|
{
|
2020-01-21 16:17:59 +01:00
|
|
|
setDisplayName(QnxDevice::tr("QNX Device"));
|
2019-02-20 19:13:28 +01:00
|
|
|
setCombinedIcon(":/qnx/images/qnxdevicesmall.png",
|
|
|
|
|
":/qnx/images/qnxdevice.png");
|
|
|
|
|
setCanCreate(true);
|
|
|
|
|
setConstructionFunction(&QnxDevice::create);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::IDevice::Ptr QnxDeviceFactory::create() const
|
|
|
|
|
{
|
|
|
|
|
QnxDeviceWizard wizard;
|
|
|
|
|
if (wizard.exec() != QDialog::Accepted)
|
|
|
|
|
return ProjectExplorer::IDevice::Ptr();
|
|
|
|
|
return wizard.device();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
2014-11-27 17:46:45 +01:00
|
|
|
} // namespace Qnx
|