aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/ios/iosdeploystep.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/ios/iosdeploystep.cpp')
-rw-r--r--src/plugins/ios/iosdeploystep.cpp101
1 files changed, 75 insertions, 26 deletions
diff --git a/src/plugins/ios/iosdeploystep.cpp b/src/plugins/ios/iosdeploystep.cpp
index 329fab7bfd..cdb2199ba6 100644
--- a/src/plugins/ios/iosdeploystep.cpp
+++ b/src/plugins/ios/iosdeploystep.cpp
@@ -24,13 +24,15 @@
****************************************************************************/
#include "iosdeploystep.h"
+
#include "iosbuildstep.h"
+#include "iosconfigurations.h"
#include "iosconstants.h"
+#include "iosdevice.h"
#include "iosrunconfiguration.h"
+#include "iossimulator.h"
#include "iostoolhandler.h"
-#include <coreplugin/messagemanager.h>
-
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
@@ -39,23 +41,65 @@
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/devicesupport/devicemanager.h>
-#include <qtsupport/qtkitinformation.h>
-
#include <utils/temporaryfile.h>
#include <QDir>
#include <QFile>
#include <QSettings>
-#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
-
using namespace ProjectExplorer;
using namespace Utils;
namespace Ios {
namespace Internal {
-IosDeployStep::IosDeployStep(BuildStepList *parent, Core::Id id)
+class IosDeployStep final : public BuildStep
+{
+ Q_DECLARE_TR_FUNCTIONS(Ios::Internal::IosDeployStep)
+
+public:
+ enum TransferStatus {
+ NoTransfer,
+ TransferInProgress,
+ TransferOk,
+ TransferFailed
+ };
+
+ IosDeployStep(BuildStepList *bc, Utils::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, Utils::Id id)
: BuildStep(parent, id)
{
setImmutable(true);
@@ -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;
@@ -104,7 +142,7 @@ bool IosDeployStep::init()
void IosDeployStep::doRun()
{
QTC_CHECK(m_transferStatus == NoTransfer);
- if (device().isNull()) {
+ if (m_device.isNull()) {
TaskHub::addTask(
DeploymentTask(Task::Error, tr("Deployment failed. No iOS device found.")));
emit finished(!iossimulator().isNull());
@@ -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));
@@ -245,9 +283,9 @@ void IosDeployStep::checkProvisioningProfile()
if (!provisionPlist.contains(QLatin1String("ProvisionedDevices")))
return;
- QStringList deviceIds = provisionPlist.value(QLatin1String("ProvisionedDevices")).toStringList();
- QString targetId = device->uniqueDeviceID();
- foreach (const QString &deviceId, deviceIds) {
+ const QStringList deviceIds = provisionPlist.value("ProvisionedDevices").toStringList();
+ const QString targetId = device->uniqueDeviceID();
+ for (const QString &deviceId : deviceIds) {
if (deviceId == targetId)
return;
}
@@ -263,11 +301,6 @@ void IosDeployStep::checkProvisioningProfile()
emit addTask(task);
}
-IDevice::ConstPtr IosDeployStep::device() const
-{
- return m_device;
-}
-
IosDevice::ConstPtr IosDeployStep::iosdevice() const
{
return m_device.dynamicCast<const IosDevice>();
@@ -278,5 +311,21 @@ IosSimulator::ConstPtr IosDeployStep::iossimulator() const
return m_device.dynamicCast<const IosSimulator>();
}
+// IosDeployStepFactory
+
+IosDeployStepFactory::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);
+}
+
+Utils::Id IosDeployStepFactory::stepId()
+{
+ return "Qt4ProjectManager.IosDeployStep";
+}
+
} // namespace Internal
} // namespace Ios