diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index bd4aa5029d7..d4bfe94e9e7 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -34,7 +34,8 @@ SOURCES += qnxplugin.cpp \ qnxconfigurationmanager.cpp \ qnxsettingspage.cpp \ qnxversionnumber.cpp \ - qnxdeployqtlibrariesdialog.cpp + qnxdeployqtlibrariesdialog.cpp \ + qnxdeviceprocess.cpp HEADERS += qnxplugin.h\ qnxconstants.h \ @@ -69,14 +70,16 @@ HEADERS += qnxplugin.h\ qnxconfigurationmanager.h \ qnxsettingspage.h \ qnxversionnumber.h \ - qnxdeployqtlibrariesdialog.h + qnxdeployqtlibrariesdialog.h \ + qnx_export.h \ + qnxdeviceprocess.h FORMS += \ qnxsettingswidget.ui \ qnxdeployqtlibrariesdialog.ui -DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII +DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII QNX_LIBRARY RESOURCES += \ qnx.qrc diff --git a/src/plugins/qnx/qnx_export.h b/src/plugins/qnx/qnx_export.h new file mode 100644 index 00000000000..46c321d5acb --- /dev/null +++ b/src/plugins/qnx/qnx_export.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** 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 +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QNX_EXPORT_H +#define QNX_EXPORT_H + +#include + +#if defined(QNX_LIBRARY) +# define QNX_EXPORT Q_DECL_EXPORT +#else +# define QNX_EXPORT Q_DECL_IMPORT +#endif + +#endif // QNX_EXPORT_H diff --git a/src/plugins/qnx/qnxdeviceconfiguration.cpp b/src/plugins/qnx/qnxdeviceconfiguration.cpp index 06998bc8015..d24aae59709 100644 --- a/src/plugins/qnx/qnxdeviceconfiguration.cpp +++ b/src/plugins/qnx/qnxdeviceconfiguration.cpp @@ -35,11 +35,11 @@ #include "qnxdeviceprocesslist.h" #include "qnxdeviceprocesssignaloperation.h" #include "qnxdeployqtlibrariesdialog.h" +#include "qnxdeviceprocess.h" #include #include #include -#include #include #include @@ -50,51 +50,12 @@ using namespace ProjectExplorer; using namespace Utils; namespace Qnx { -namespace Internal { + +using namespace Internal; const char QnxVersionKey[] = "QnxVersion"; const char DeployQtLibrariesActionId [] = "Qnx.Qnx.DeployQtLibrariesAction"; -static int pidFileCounter = 0; - -QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer &device, QObject *parent) - : SshDeviceProcess(device, parent) -{ - setEnvironment(Environment(OsTypeLinux)); - m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter); -} - -QString QnxDeviceProcess::fullCommandLine() const -{ - QStringList args = arguments(); - args.prepend(executable()); - QString cmd = QtcProcess::Arguments::createUnixArgs(args).toString(); - - QString fullCommandLine = QLatin1String( - "test -f /etc/profile && . /etc/profile ; " - "test -f $HOME/profile && . $HOME/profile ; " - ); - - if (!m_workingDir.isEmpty()) - fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(QtcProcess::quoteArg(m_workingDir)); - - for (auto it = environment().constBegin(); it != environment().constEnd(); ++it) - fullCommandLine += QString::fromLatin1("%1='%2' ").arg(it.key()).arg(it.value()); - - fullCommandLine += QString::fromLatin1("%1 & echo $! > %2").arg(cmd).arg(m_pidFile); - - return fullCommandLine; -} - -void QnxDeviceProcess::doSignal(int sig) -{ - auto signaler = new SshDeviceProcess(device(), this); - QString cmd = QString::fromLatin1("kill -%2 `cat %1`").arg(m_pidFile).arg(sig); - connect(signaler, &SshDeviceProcess::finished, signaler, &QObject::deleteLater); - signaler->start(cmd, QStringList()); -} - - class QnxPortsGatheringMethod : public PortsGatheringMethod { // TODO: The command is probably needlessly complicated because the parsing method @@ -276,5 +237,4 @@ DeviceProcessSignalOperation::Ptr QnxDeviceConfiguration::signalOperation() cons new QnxDeviceProcessSignalOperation(sshParameters())); } -} // namespace Internal } // namespace Qnx diff --git a/src/plugins/qnx/qnxdeviceconfiguration.h b/src/plugins/qnx/qnxdeviceconfiguration.h index 212716a705c..22a904d8a9e 100644 --- a/src/plugins/qnx/qnxdeviceconfiguration.h +++ b/src/plugins/qnx/qnxdeviceconfiguration.h @@ -33,31 +33,13 @@ #ifndef QNX_INTERNAL_QNXDEVICECONFIGURATION_H #define QNX_INTERNAL_QNXDEVICECONFIGURATION_H +#include "qnx_export.h" + #include -#include namespace Qnx { -namespace Internal { -class QnxDeviceProcess : public ProjectExplorer::SshDeviceProcess -{ -public: - QnxDeviceProcess(const QSharedPointer &device, QObject *parent); - - void setWorkingDirectory(const QString &directory) { m_workingDir = directory; } - - void interrupt() { doSignal(2); } - void terminate() { doSignal(15); } - void kill() { doSignal(9); } - QString fullCommandLine() const; - -private: - void doSignal(int sig); - QString m_pidFile; - QString m_workingDir; -}; - -class QnxDeviceConfiguration : public RemoteLinux::LinuxDevice +class QNX_EXPORT QnxDeviceConfiguration : public RemoteLinux::LinuxDevice { Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxDeviceConfiguration) @@ -103,7 +85,6 @@ private: mutable int m_versionNumber; }; -} // namespace Internal } // namespace Qnx #endif // QNX_INTERNAL_QNXDEVICECONFIGURATION_H diff --git a/src/plugins/qnx/qnxdeviceprocess.cpp b/src/plugins/qnx/qnxdeviceprocess.cpp new file mode 100644 index 00000000000..c13cffb1b0d --- /dev/null +++ b/src/plugins/qnx/qnxdeviceprocess.cpp @@ -0,0 +1,84 @@ +/************************************************************************** +** +** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.com) +** Contact: KDAB (info@kdab.com) +** +** 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 +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "qnxdeviceprocess.h" + +#include +#include + +using namespace ProjectExplorer; +using namespace Utils; + +namespace Qnx { +namespace Internal { + +static int pidFileCounter = 0; + +QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer &device, QObject *parent) + : SshDeviceProcess(device, parent) +{ + setEnvironment(Environment(OsTypeLinux)); + m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter); +} + +QString QnxDeviceProcess::fullCommandLine() const +{ + QStringList args = arguments(); + args.prepend(executable()); + QString cmd = QtcProcess::Arguments::createUnixArgs(args).toString(); + + QString fullCommandLine = QLatin1String( + "test -f /etc/profile && . /etc/profile ; " + "test -f $HOME/profile && . $HOME/profile ; " + ); + + if (!m_workingDir.isEmpty()) + fullCommandLine += QString::fromLatin1("cd %1 ; ").arg(QtcProcess::quoteArg(m_workingDir)); + + for (auto it = environment().constBegin(); it != environment().constEnd(); ++it) + fullCommandLine += QString::fromLatin1("%1='%2' ").arg(it.key()).arg(it.value()); + + fullCommandLine += QString::fromLatin1("%1 & echo $! > %2").arg(cmd).arg(m_pidFile); + + return fullCommandLine; +} + +void QnxDeviceProcess::doSignal(int sig) +{ + auto signaler = new SshDeviceProcess(device(), this); + QString cmd = QString::fromLatin1("kill -%2 `cat %1`").arg(m_pidFile).arg(sig); + connect(signaler, &SshDeviceProcess::finished, signaler, &QObject::deleteLater); + signaler->start(cmd, QStringList()); +} + +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/qnx/qnxdeviceprocess.h b/src/plugins/qnx/qnxdeviceprocess.h new file mode 100644 index 00000000000..311257a0f40 --- /dev/null +++ b/src/plugins/qnx/qnxdeviceprocess.h @@ -0,0 +1,64 @@ +/************************************************************************** +** +** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. +** +** Contact: BlackBerry (qt@blackberry.com) +** Contact: KDAB (info@kdab.com) +** +** 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 +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QNXDEVICEPROCESS_H +#define QNXDEVICEPROCESS_H + +#include "qnx_export.h" +#include +#include + +namespace Qnx { +namespace Internal { + +class QnxDeviceProcess : public ProjectExplorer::SshDeviceProcess +{ +public: + QnxDeviceProcess(const QSharedPointer &device, QObject *parent); + + void setWorkingDirectory(const QString &directory) { m_workingDir = directory; } + + void interrupt() { doSignal(2); } + void terminate() { doSignal(15); } + void kill() { doSignal(9); } + QString fullCommandLine() const; + +private: + void doSignal(int sig); + QString m_pidFile; + QString m_workingDir; +}; + +} // namespace Internal +} // namespace Qnx + +#endif // QNXDEVICEPROCESS_H diff --git a/src/plugins/qnx/qnxdeviceprocesssignaloperation.h b/src/plugins/qnx/qnxdeviceprocesssignaloperation.h index 99b64324977..3d313ba6348 100644 --- a/src/plugins/qnx/qnxdeviceprocesssignaloperation.h +++ b/src/plugins/qnx/qnxdeviceprocesssignaloperation.h @@ -36,6 +36,8 @@ #include namespace Qnx { +class QnxDeviceConfiguration; + namespace Internal { class QnxDeviceProcessSignalOperation : public RemoteLinux::RemoteLinuxSignalOperation @@ -48,7 +50,7 @@ private: QString killProcessByNameCommandLine(const QString &filePath) const; QString interruptProcessByNameCommandLine(const QString &filePath) const; - friend class QnxDeviceConfiguration; + friend class Qnx::QnxDeviceConfiguration; }; } // namespace Internal diff --git a/src/plugins/qnx/slog2inforunner.cpp b/src/plugins/qnx/slog2inforunner.cpp index 504ea6c0517..4eea0200a76 100644 --- a/src/plugins/qnx/slog2inforunner.cpp +++ b/src/plugins/qnx/slog2inforunner.cpp @@ -32,7 +32,7 @@ #include "slog2inforunner.h" -#include "qnxdeviceconfiguration.h" +#include "qnxdeviceprocess.h" #include