diff --git a/src/plugins/ios/iosdeploystep.cpp b/src/plugins/ios/iosdeploystep.cpp index 329fab7bfdb..6609714e986 100644 --- a/src/plugins/ios/iosdeploystep.cpp +++ b/src/plugins/ios/iosdeploystep.cpp @@ -24,12 +24,14 @@ ****************************************************************************/ #include "iosdeploystep.h" -#include "iosbuildstep.h" -#include "iosconstants.h" -#include "iosrunconfiguration.h" -#include "iostoolhandler.h" -#include +#include "iosbuildstep.h" +#include "iosconfigurations.h" +#include "iosconstants.h" +#include "iosdevice.h" +#include "iosrunconfiguration.h" +#include "iossimulator.h" +#include "iostoolhandler.h" #include #include @@ -39,22 +41,64 @@ #include #include -#include - #include #include #include #include -#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state) - using namespace ProjectExplorer; using namespace Utils; namespace Ios { namespace Internal { +class IosDeployStep final : public BuildStep +{ + Q_DECLARE_TR_FUNCTIONS(Ios::Internal::IosDeployStep) + +public: + enum TransferStatus { + NoTransfer, + TransferInProgress, + TransferOk, + TransferFailed + }; + + IosDeployStep(BuildStepList *bc, Core::Id id); + +private: + void cleanup(); + + void doRun() final; + void doCancel() final; + + void handleIsTransferringApp(IosToolHandler *handler, const QString &bundlePath, + const QString &deviceId, int progress, int maxProgress, + const QString &info); + void handleDidTransferApp(IosToolHandler *handler, const QString &bundlePath, const QString &deviceId, + IosToolHandler::OpStatus status); + void handleFinished(IosToolHandler *handler); + void handleErrorMsg(IosToolHandler *handler, const QString &msg); + void updateDisplayNames(); + + bool init() final; + BuildStepConfigWidget *createConfigWidget() final; + IDevice::ConstPtr device() const; + IosDevice::ConstPtr iosdevice() const; + IosSimulator::ConstPtr iossimulator() const; + + QString deviceId() const; + void checkProvisioningProfile(); + + TransferStatus m_transferStatus = NoTransfer; + IosToolHandler *m_toolHandler = nullptr; + IDevice::ConstPtr m_device; + FilePath m_bundlePath; + IosDeviceType m_deviceType; + bool m_expectFail = false; +}; + IosDeployStep::IosDeployStep(BuildStepList *parent, Core::Id id) : BuildStep(parent, id) { @@ -66,15 +110,9 @@ IosDeployStep::IosDeployStep(BuildStepList *parent, Core::Id id) this, &IosDeployStep::updateDisplayNames); } -Core::Id IosDeployStep::stepId() -{ - return "Qt4ProjectManager.IosDeployStep"; -} - void IosDeployStep::updateDisplayNames() { - IDevice::ConstPtr dev = - DeviceKitAspect::device(target()->kit()); + IDevice::ConstPtr dev = DeviceKitAspect::device(target()->kit()); const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName(); setDefaultDisplayName(tr("Deploy to %1").arg(devName)); setDisplayName(tr("Deploy to %1").arg(devName)); @@ -95,7 +133,7 @@ bool IosDeployStep::init() m_deviceType = runConfig->deviceType(); } else { emit addOutput(tr("Error: no device available, deploy failed."), - BuildStep::OutputFormat::ErrorMessage); + OutputFormat::ErrorMessage); return false; } return true; @@ -190,7 +228,7 @@ void IosDeployStep::handleErrorMsg(IosToolHandler *handler, const QString &msg) if (msg.contains(QLatin1String("AMDeviceInstallApplication returned -402653103"))) TaskHub::addTask(DeploymentTask(Task::Warning, tr("The Info.plist might be incorrect."))); - emit addOutput(msg, BuildStep::OutputFormat::ErrorMessage); + emit addOutput(msg, OutputFormat::ErrorMessage); } BuildStepConfigWidget *IosDeployStep::createConfigWidget() @@ -236,7 +274,7 @@ void IosDeployStep::checkProvisioningProfile() return; end += 8; - Utils::TemporaryFile f("iosdeploy"); + TemporaryFile f("iosdeploy"); if (!f.open()) return; f.write(provisionData.mid(start, end - start)); @@ -278,5 +316,21 @@ IosSimulator::ConstPtr IosDeployStep::iossimulator() const return m_device.dynamicCast(); } +// IosDeployStepFactory + +IosDeployStepFactory::IosDeployStepFactory() +{ + registerStep(stepId()); + setDisplayName(IosDeployStep::tr("Deploy to iOS device or emulator")); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); + setSupportedDeviceTypes({Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE}); + setRepeatable(false); +} + +Core::Id IosDeployStepFactory::stepId() +{ + return "Qt4ProjectManager.IosDeployStep"; +} + } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosdeploystep.h b/src/plugins/ios/iosdeploystep.h index 909aae4f4d6..bdd23a74f7f 100644 --- a/src/plugins/ios/iosdeploystep.h +++ b/src/plugins/ios/iosdeploystep.h @@ -25,64 +25,17 @@ #pragma once -#include "iosconfigurations.h" -#include "iosdevice.h" -#include "iossimulator.h" - #include -#include - -#include namespace Ios { -class IosToolHandler; namespace Internal { -class IosDeployStep : public ProjectExplorer::BuildStep +class IosDeployStepFactory final : public ProjectExplorer::BuildStepFactory { - Q_OBJECT public: - enum TransferStatus { - NoTransfer, - TransferInProgress, - TransferOk, - TransferFailed - }; + IosDeployStepFactory(); - friend class IosDeployStepFactory; - IosDeployStep(ProjectExplorer::BuildStepList *bc, Core::Id id); static Core::Id stepId(); - - void cleanup(); -private: - void doRun() override; - void doCancel() override; - - void handleIsTransferringApp(Ios::IosToolHandler *handler, const QString &bundlePath, - const QString &deviceId, int progress, int maxProgress, - const QString &info); - void handleDidTransferApp(Ios::IosToolHandler *handler, const QString &bundlePath, const QString &deviceId, - Ios::IosToolHandler::OpStatus status); - void handleFinished(Ios::IosToolHandler *handler); - void handleErrorMsg(Ios::IosToolHandler *handler, const QString &msg); - void updateDisplayNames(); - - bool init() override; - ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override; - ProjectExplorer::IDevice::ConstPtr device() const; - IosDevice::ConstPtr iosdevice() const; - IosSimulator::ConstPtr iossimulator() const; - - QString deviceId() const; - void checkProvisioningProfile(); - - TransferStatus m_transferStatus = NoTransfer; - IosToolHandler *m_toolHandler = nullptr; - ProjectExplorer::IDevice::ConstPtr m_device; - Utils::FilePath m_bundlePath; - IosDeviceType m_deviceType; - static const Core::Id Id; - bool m_expectFail = false; }; } // namespace Internal diff --git a/src/plugins/ios/iosplugin.cpp b/src/plugins/ios/iosplugin.cpp index 50540c331f1..a112364735c 100644 --- a/src/plugins/ios/iosplugin.cpp +++ b/src/plugins/ios/iosplugin.cpp @@ -53,19 +53,6 @@ namespace Internal { Q_LOGGING_CATEGORY(iosLog, "qtc.ios.common", QtWarningMsg) -class IosDeployStepFactory : public BuildStepFactory -{ -public: - IosDeployStepFactory() - { - registerStep(IosDeployStep::stepId()); - setDisplayName(IosDeployStep::tr("Deploy to iOS device or emulator")); - setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY); - setSupportedDeviceTypes({Constants::IOS_DEVICE_TYPE, Constants::IOS_SIMULATOR_TYPE}); - setRepeatable(false); - } -}; - class IosDeployConfigurationFactory : public DeployConfigurationFactory { public: @@ -76,7 +63,7 @@ public: addSupportedTargetDeviceType(Constants::IOS_DEVICE_TYPE); addSupportedTargetDeviceType(Constants::IOS_SIMULATOR_TYPE); setDefaultDisplayName(QCoreApplication::translate("Ios::Internal", "Deploy on iOS")); - addInitialStep(IosDeployStep::stepId()); + addInitialStep(IosDeployStepFactory::stepId()); } };