2019-06-04 14:22:35 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2019 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://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 https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qdbmakedefaultappstep.h"
|
|
|
|
|
|
2020-02-20 13:51:49 +01:00
|
|
|
#include "qdbconstants.h"
|
2019-06-04 14:22:35 +02:00
|
|
|
|
2022-05-04 08:01:57 +02:00
|
|
|
#include <projectexplorer/devicesupport/idevice.h>
|
2022-06-22 15:43:33 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2019-06-13 18:25:17 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2022-05-04 08:01:57 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2019-06-13 18:25:17 +02:00
|
|
|
|
2022-05-27 15:41:57 +02:00
|
|
|
#include <remotelinux/abstractremotelinuxdeployservice.h>
|
2020-02-20 13:51:49 +01:00
|
|
|
#include <remotelinux/abstractremotelinuxdeploystep.h>
|
|
|
|
|
|
2022-05-04 08:01:57 +02:00
|
|
|
#include <utils/commandline.h>
|
|
|
|
|
#include <utils/qtcprocess.h>
|
|
|
|
|
|
2019-06-13 18:25:17 +02:00
|
|
|
using namespace ProjectExplorer;
|
2020-09-18 12:11:40 +02:00
|
|
|
using namespace Utils;
|
2019-06-04 14:22:35 +02:00
|
|
|
|
|
|
|
|
namespace Qdb {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2022-05-04 08:01:57 +02:00
|
|
|
// QdbMakeDefaultAppService
|
|
|
|
|
|
|
|
|
|
class QdbMakeDefaultAppService : public RemoteLinux::AbstractRemoteLinuxDeployService
|
2020-02-20 13:51:49 +01:00
|
|
|
{
|
2022-05-04 08:01:57 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(Qdb::Internal::QdbMakeDefaultAppService)
|
2020-02-20 13:51:49 +01:00
|
|
|
|
|
|
|
|
public:
|
2022-05-04 08:01:57 +02:00
|
|
|
QdbMakeDefaultAppService()
|
|
|
|
|
{
|
|
|
|
|
connect(&m_process, &QtcProcess::done, this, [this] {
|
|
|
|
|
if (m_process.error() != QProcess::UnknownError)
|
|
|
|
|
emit errorMessage(tr("Remote process failed: %1").arg(m_process.errorString()));
|
|
|
|
|
else if (m_makeDefault)
|
|
|
|
|
emit progressMessage(tr("Application set as the default one."));
|
|
|
|
|
else
|
|
|
|
|
emit progressMessage(tr("Reset the default application."));
|
|
|
|
|
|
|
|
|
|
stopDeployment();
|
|
|
|
|
});
|
|
|
|
|
connect(&m_process, &QtcProcess::readyReadStandardError, this, [this] {
|
|
|
|
|
emit stdErrData(QString::fromUtf8(m_process.readAllStandardError()));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setMakeDefault(bool makeDefault)
|
|
|
|
|
{
|
|
|
|
|
m_makeDefault = makeDefault;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool isDeploymentNecessary() const final { return true; }
|
|
|
|
|
|
|
|
|
|
void doDeploy() final
|
|
|
|
|
{
|
|
|
|
|
QString remoteExe;
|
|
|
|
|
|
|
|
|
|
if (RunConfiguration *rc = target()->activeRunConfiguration()) {
|
|
|
|
|
if (auto exeAspect = rc->aspect<ExecutableAspect>())
|
|
|
|
|
remoteExe = exeAspect->executable().toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString args = m_makeDefault && !remoteExe.isEmpty()
|
|
|
|
|
? QStringLiteral("--make-default ") + remoteExe
|
|
|
|
|
: QStringLiteral("--remove-default");
|
|
|
|
|
m_process.setCommand(
|
2022-05-10 15:33:33 +02:00
|
|
|
{deviceConfiguration()->filePath(Constants::AppcontrollerFilepath), {args}});
|
2022-05-04 08:01:57 +02:00
|
|
|
m_process.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void stopDeployment() final
|
|
|
|
|
{
|
|
|
|
|
m_process.close();
|
|
|
|
|
handleDeploymentDone();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool m_makeDefault = true;
|
|
|
|
|
QtcProcess m_process;
|
2020-02-20 13:51:49 +01:00
|
|
|
};
|
|
|
|
|
|
2022-05-04 08:01:57 +02:00
|
|
|
|
|
|
|
|
// QdbMakeDefaultAppStep
|
|
|
|
|
|
|
|
|
|
class QdbMakeDefaultAppStep final : public RemoteLinux::AbstractRemoteLinuxDeployStep
|
2019-06-04 14:22:35 +02:00
|
|
|
{
|
2022-05-04 08:01:57 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(Qdb::Internal::QdbMakeDefaultAppStep)
|
2019-06-04 14:22:35 +02:00
|
|
|
|
2022-05-04 08:01:57 +02:00
|
|
|
public:
|
|
|
|
|
QdbMakeDefaultAppStep(BuildStepList *bsl, Id id)
|
|
|
|
|
: AbstractRemoteLinuxDeployStep(bsl, id)
|
|
|
|
|
{
|
|
|
|
|
auto service = createDeployService<QdbMakeDefaultAppService>();
|
|
|
|
|
|
|
|
|
|
auto selection = addAspect<SelectionAspect>();
|
|
|
|
|
selection->setSettingsKey("QdbMakeDefaultDeployStep.MakeDefault");
|
|
|
|
|
selection->addOption(tr("Set this application to start by default"));
|
|
|
|
|
selection->addOption(tr("Reset default application"));
|
|
|
|
|
|
|
|
|
|
setInternalInitializer([service, selection] {
|
|
|
|
|
service->setMakeDefault(selection->value() == 0);
|
|
|
|
|
return service->isDeploymentPossible();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
2019-06-13 18:25:17 +02:00
|
|
|
|
2019-06-04 14:22:35 +02:00
|
|
|
|
2020-02-20 13:51:49 +01:00
|
|
|
// QdbMakeDefaultAppStepFactory
|
2019-06-04 14:22:35 +02:00
|
|
|
|
2020-02-20 13:51:49 +01:00
|
|
|
QdbMakeDefaultAppStepFactory::QdbMakeDefaultAppStepFactory()
|
2019-06-04 14:22:35 +02:00
|
|
|
{
|
2020-02-20 13:51:49 +01:00
|
|
|
registerStep<QdbMakeDefaultAppStep>(Constants::QdbMakeDefaultAppStepId);
|
2020-09-24 17:29:46 +02:00
|
|
|
setDisplayName(QdbMakeDefaultAppStep::tr("Change default application"));
|
2020-02-20 13:51:49 +01:00
|
|
|
setSupportedDeviceType(Qdb::Constants::QdbLinuxOsType);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
|
2019-06-04 14:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qdb
|