QString IosRunConfiguration::disabledReason() const { if (m_parseInProgress) return tr("The .pro file \"%1\" is currently being parsed.") .arg(QFileInfo(m_profilePath).fileName()); if (!m_parseSuccess) return static_cast<QmakeProject *>(target()->project()) ->disabledReasonForRunConfiguration(m_profilePath); Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit()); if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE) return tr("Kit has incorrect device type for running on iOS devices."); IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); QString validDevName; bool hasConncetedDev = false; if (devType == Constants::IOS_DEVICE_TYPE) { DeviceManager *dm = DeviceManager::instance(); for (int idev = 0; idev < dm->deviceCount(); ++idev) { IDevice::ConstPtr availDev = dm->deviceAt(idev); if (!availDev.isNull() && availDev->type() == Constants::IOS_DEVICE_TYPE) { if (availDev->deviceState() == IDevice::DeviceReadyToUse) { validDevName += QLatin1Char(' '); validDevName += availDev->displayName(); } else if (availDev->deviceState() == IDevice::DeviceConnected) { hasConncetedDev = true; } } } } if (dev.isNull()) { if (!validDevName.isEmpty()) return tr("No device chosen. Select %1.").arg(validDevName); // should not happen else if (hasConncetedDev) return tr("No device chosen. Enable developer mode on a device."); // should not happen else return tr("No device available."); } else { switch (dev->deviceState()) { case IDevice::DeviceReadyToUse: break; case IDevice::DeviceConnected: return tr("To use this device you need to enable developer mode on it."); case IDevice::DeviceDisconnected: case IDevice::DeviceStateUnknown: if (!validDevName.isEmpty()) return tr("%1 is not connected. Select %2?") .arg(dev->displayName(), validDevName); else if (hasConncetedDev) return tr("%1 is not connected. Enable developer mode on a device?") .arg(dev->displayName()); else return tr("%1 is not connected.").arg(dev->displayName()); } } return RunConfiguration::disabledReason(); }
bool MerLocalRsyncDeployStep::init() { Qt4ProjectManager::Qt4BuildConfiguration *bc = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration*>(buildConfiguration()); if (!bc) bc = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration*>(target()->activeBuildConfiguration()); if (!bc) { addOutput(tr("Cannot deploy: No active build configuration."), ErrorMessageOutput); return false; } const MerSdk *const merSdk = MerSdkKitInformation::sdk(target()->kit()); if (!merSdk) { addOutput(tr("Cannot deploy: Missing MerSdk information in the kit"),ErrorMessageOutput); return false; } const QString target = MerTargetKitInformation::targetName(this->target()->kit()); if (target.isEmpty()) { addOutput(tr("Cannot deploy: Missing MerTarget information in the kit"),ErrorMessageOutput); return false; } IDevice::ConstPtr device = DeviceKitInformation::device(this->target()->kit()); //TODO: HACK if (device.isNull() && DeviceTypeKitInformation::deviceTypeId(this->target()->kit()) != Constants::MER_DEVICE_TYPE_ARM) { addOutput(tr("Cannot deploy: Missing MerDevice information in the kit"),ErrorMessageOutput); return false; } const QString projectDirectory = bc->shadowBuild() ? bc->shadowBuildDirectory() : project()->projectDirectory(); const QString deployCommand = QLatin1String("rsync"); ProcessParameters *pp = processParameters(); Utils::Environment env = bc ? bc->environment() : Utils::Environment::systemEnvironment(); //TODO HACK if(!device.isNull()) env.appendOrSet(QLatin1String(Constants::MER_SSH_DEVICE_NAME),device->displayName()); pp->setMacroExpander(bc ? bc->macroExpander() : Core::VariableManager::instance()->macroExpander()); pp->setEnvironment(env); pp->setWorkingDirectory(projectDirectory); pp->setCommand(deployCommand); pp->setArguments(arguments()); return AbstractProcessStep::init(); }
static DebuggerStartParameters createDebuggerStartParameters(QnxRunConfiguration *runConfig) { DebuggerStartParameters params; Target *target = runConfig->target(); Kit *k = target->kit(); const IDevice::ConstPtr device = DeviceKitInformation::device(k); if (device.isNull()) return params; params.startMode = AttachToRemoteServer; params.useCtrlCStub = true; params.inferior.executable = runConfig->localExecutableFilePath(); params.remoteExecutable = runConfig->remoteExecutableFilePath(); params.remoteChannel = device->sshParameters().host + QLatin1String(":-1"); params.remoteSetupNeeded = true; params.closeMode = KillAtClose; params.inferior.commandLineArguments = runConfig->arguments(); auto aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>(); if (aspect->useQmlDebugger()) { params.qmlServerAddress = device->sshParameters().host; params.qmlServerPort = 0; // QML port is handed out later } auto qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(k)); if (qtVersion) params.solibSearchPath = QnxUtils::searchPaths(qtVersion); return params; }
bool TypeSpecificDeviceConfigurationListModel::deviceMatches(IDevice::ConstPtr dev) const { if (dev.isNull()) return false; Core::Id typeId = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target()->kit()); return dev->type() == typeId; }
RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runConfig, QString *errorMessage) { Q_UNUSED(errorMessage); Target *target = runConfig->target(); if (!target) return 0; IDevice::ConstPtr device = DeviceKitInformation::device(target->kit()); if (device.isNull()) return 0; AnalyzerStartParameters params; params.runMode = QmlProfilerRunMode; params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString(); params.debuggee = runConfig->localExecutable().toUserOutput(); params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments()); params.analyzerHost = QLatin1String("localhost"); if (device->type() == Core::Id(Ios::Constants::IOS_DEVICE_TYPE)) { IosDevice::ConstPtr iosDevice = device.dynamicCast<const IosDevice>(); if (iosDevice.isNull()) return 0; } params.displayName = runConfig->applicationName(); AnalyzerRunControl *analyzerRunControl = AnalyzerManager::createRunControl(params, runConfig); (void) new IosAnalyzeSupport(runConfig, analyzerRunControl, false, true); return analyzerRunControl; }
void IosDeviceManager::deviceConnected(const QString &uid, const QString &name) { DeviceManager *devManager = DeviceManager::instance(); Core::Id baseDevId(Constants::IOS_DEVICE_ID); Core::Id devType(Constants::IOS_DEVICE_TYPE); Core::Id devId = baseDevId.withSuffix(uid); IDevice::ConstPtr dev = devManager->find(devId); if (dev.isNull()) { IosDevice *newDev = new IosDevice(uid); if (!name.isNull()) newDev->setDisplayName(name); qCDebug(detectLog) << "adding ios device " << uid; devManager->addDevice(IDevice::ConstPtr(newDev)); } else if (dev->deviceState() != IDevice::DeviceConnected && dev->deviceState() != IDevice::DeviceReadyToUse) { qCDebug(detectLog) << "updating ios device " << uid; IosDevice *newDev = 0; if (dev->type() == devType) { const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data()); newDev = new IosDevice(*iosDev); } else { newDev = new IosDevice(uid); } devManager->addDevice(IDevice::ConstPtr(newDev)); } updateInfo(uid); }
void DeviceSettingsWidget::currentDeviceChanged(int index) { qDeleteAll(m_additionalActionButtons); delete m_configWidget; m_configWidget = 0; m_additionalActionButtons.clear(); const IDevice::ConstPtr device = m_deviceManagerModel->device(index); if (device.isNull()) { m_ui->removeConfigButton->setEnabled(false); clearDetails(); m_ui->defaultDeviceButton->setEnabled(false); } else { m_ui->removeConfigButton->setEnabled(true); foreach (const Core::Id actionId, device->actionIds()) { QPushButton * const button = new QPushButton(device->displayNameForActionId(actionId)); m_additionalActionButtons << button; connect(button, SIGNAL(clicked()), m_additionalActionsMapper, SLOT(map())); m_additionalActionsMapper->setMapping(button, actionId.uniqueIdentifier()); m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button); } if (!m_ui->osSpecificGroupBox->layout()) new QVBoxLayout(m_ui->osSpecificGroupBox); int managerIndex = m_deviceManager->indexOf(device); m_configWidget = m_deviceManager->mutableDeviceAt(managerIndex)->createWidget(); if (m_configWidget) m_ui->osSpecificGroupBox->layout()->addWidget(m_configWidget); displayCurrent(); } }
static AnalyzerStartParameters createAnalyzerStartParameters(const QnxRunConfiguration *runConfig, RunMode mode) { AnalyzerStartParameters params; Target *target = runConfig->target(); Kit *k = target->kit(); const IDevice::ConstPtr device = DeviceKitInformation::device(k); if (device.isNull()) return params; if (mode == QmlProfilerRunMode) params.startMode = StartLocal; params.runMode = mode; params.debuggee = runConfig->remoteExecutableFilePath(); params.debuggeeArgs = runConfig->arguments().join(QLatin1Char(' ')); params.connParams = DeviceKitInformation::device(runConfig->target()->kit())->sshParameters(); params.displayName = runConfig->displayName(); params.sysroot = SysRootKitInformation::sysRoot(runConfig->target()->kit()).toString(); params.analyzerHost = params.connParams.host; params.analyzerPort = params.connParams.port; if (EnvironmentAspect *environment = runConfig->extraAspect<EnvironmentAspect>()) params.environment = environment->environment(); return params; }
QList<Task> DeviceTypeKitInformation::validate(Kit *k) const { IDevice::ConstPtr dev = DeviceKitInformation::device(k); QList<Task> result; if (!dev.isNull() && dev->type() != DeviceTypeKitInformation::deviceTypeId(k)) result.append(Task(Task::Error, tr("Device does not match device type."), Utils::FileName(), -1, Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM))); return result; }
void IosRunConfiguration::updateDisplayNames() { if (DeviceTypeKitInformation::deviceTypeId(target()->kit()) == Constants::IOS_DEVICE_TYPE) m_deviceType = IosDeviceType(IosDeviceType::IosDevice); else if (m_deviceType.type == IosDeviceType::IosDevice) m_deviceType = IosDeviceType(IosDeviceType::SimulatedDevice); IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); const QString devName = dev.isNull() ? IosDevice::name() : dev->displayName(); setDefaultDisplayName(tr("Run on %1").arg(devName)); setDisplayName(tr("Run %1 on %2").arg(applicationName()).arg(devName)); }
bool MerEmulatorStartStep::init() { IDevice::ConstPtr d = DeviceKitInformation::device(this->target()->kit()); if(d.isNull() || d->type() != Constants::MER_DEVICE_TYPE_I486) { setEnabled(false); return false; } const MerEmulatorDevice* device = static_cast<const MerEmulatorDevice*>(d.data()); m_vm = device->virtualMachine(); m_ssh = device->sshParameters(); return !m_vm.isEmpty(); }
bool IosRunConfiguration::isEnabled() const { if (m_parseInProgress || !m_parseSuccess) return false; Core::Id devType = DeviceTypeKitInformation::deviceTypeId(target()->kit()); if (devType != Constants::IOS_DEVICE_TYPE && devType != Constants::IOS_SIMULATOR_TYPE) return false; IDevice::ConstPtr dev = DeviceKitInformation::device(target()->kit()); if (dev.isNull() || dev->deviceState() != IDevice::DeviceReadyToUse) return false; return RunConfiguration::isEnabled(); }
static DebuggerStartParameters createDebuggerStartParameters(QnxRunConfiguration *runConfig) { DebuggerStartParameters params; Target *target = runConfig->target(); Kit *k = target->kit(); const IDevice::ConstPtr device = DeviceKitInformation::device(k); if (device.isNull()) return params; params.startMode = AttachToRemoteServer; params.debuggerCommand = DebuggerKitInformation::debuggerCommand(k).toString(); params.sysRoot = SysRootKitInformation::sysRoot(k).toString(); params.useCtrlCStub = true; params.runConfiguration = runConfig; if (ToolChain *tc = ToolChainKitInformation::toolChain(k)) params.toolChainAbi = tc->targetAbi(); params.executable = runConfig->localExecutableFilePath(); params.remoteExecutable = runConfig->remoteExecutableFilePath(); params.remoteChannel = device->sshParameters().host + QLatin1String(":-1"); params.displayName = runConfig->displayName(); params.remoteSetupNeeded = true; params.closeMode = KillAtClose; params.processArgs = runConfig->arguments().join(QLatin1Char(' ')); DebuggerRunConfigurationAspect *aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>(); if (aspect->useQmlDebugger()) { params.languages |= QmlLanguage; params.qmlServerAddress = device->sshParameters().host; params.qmlServerPort = 0; // QML port is handed out later } if (aspect->useCppDebugger()) params.languages |= CppLanguage; if (const Project *project = runConfig->target()->project()) { params.projectSourceDirectory = project->projectDirectory().toString(); if (const BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration()) params.projectBuildDirectory = buildConfig->buildDirectory().toString(); params.projectSourceFiles = project->files(Project::ExcludeGeneratedFiles); } QnxQtVersion *qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtKitInformation::qtVersion(k)); if (qtVersion) params.solibSearchPath = QnxUtils::searchPaths(qtVersion); return params; }
QList<Task> QmlProject::projectIssues(const Kit *k) const { QList<Task> result = Project::projectIssues(k); const QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); if (!version) result.append(createProjectTask(Task::TaskType::Error, tr("No Qt version set in kit."))); IDevice::ConstPtr dev = DeviceKitAspect::device(k); if (dev.isNull()) result.append(createProjectTask(Task::TaskType::Error, tr("Kit has no device."))); if (version && version->qtVersion() < QtSupport::QtVersionNumber(5, 0, 0)) result.append(createProjectTask(Task::TaskType::Error, tr("Qt version is too old."))); if (dev.isNull() || !version) return result; // No need to check deeper than this if (dev->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { if (version->type() == QtSupport::Constants::DESKTOPQT) { if (static_cast<const QtSupport::DesktopQtVersion *>(version)->qmlsceneCommand().isEmpty()) { result.append(createProjectTask(Task::TaskType::Error, tr("Qt version has no qmlscene command."))); } } else { // Non-desktop Qt on a desktop device? We don't support that. result.append(createProjectTask(Task::TaskType::Error, tr("Non-desktop Qt is used with a desktop device."))); } } else { // If not a desktop device, don't check the Qt version for qmlscene. // The device is responsible for providing it and we assume qmlscene can be found // in $PATH if it's not explicitly given. } return result; }
void IosDeviceManager::updateAvailableDevices(const QStringList &devices) { foreach (const QString &uid, devices) deviceConnected(uid); DeviceManager *devManager = DeviceManager::instance(); for (int iDevice = 0; iDevice < devManager->deviceCount(); ++iDevice) { IDevice::ConstPtr dev = devManager->deviceAt(iDevice); Core::Id devType(Constants::IOS_DEVICE_TYPE); if (dev.isNull() || dev->type() != devType) continue; const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data()); if (devices.contains(iosDev->uniqueDeviceID())) continue; if (iosDev->deviceState() != IDevice::DeviceDisconnected) { qCDebug(detectLog) << "disconnecting device " << iosDev->uniqueDeviceID(); devManager->setDeviceState(iosDev->id(), IDevice::DeviceDisconnected); } } }
void IosDeviceManager::deviceDisconnected(const QString &uid) { qCDebug(detectLog) << "detected disconnection of ios device " << uid; DeviceManager *devManager = DeviceManager::instance(); Core::Id baseDevId(Constants::IOS_DEVICE_ID); Core::Id devType(Constants::IOS_DEVICE_TYPE); Core::Id devId = baseDevId.withSuffix(uid); IDevice::ConstPtr dev = devManager->find(devId); if (dev.isNull() || dev->type() != devType) { qCWarning(detectLog) << "ignoring disconnection of ios device " << uid; // should neve happen } else { const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data()); if (iosDev->m_extraInfo.isEmpty() || iosDev->m_extraInfo.value(QLatin1String("deviceName")) == QLatin1String("*unknown*")) { devManager->removeDevice(iosDev->id()); } else if (iosDev->deviceState() != IDevice::DeviceDisconnected) { qCDebug(detectLog) << "disconnecting device " << iosDev->uniqueDeviceID(); devManager->setDeviceState(iosDev->id(), IDevice::DeviceDisconnected); } } }
bool RemoteLinuxRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const { if (mode != NormalRunMode && mode != DebugRunMode && mode != DebugRunModeWithBreakOnMain) return false; const QString idStr = QString::fromLatin1(runConfiguration->id().name()); if (!runConfiguration->isEnabled() || !idStr.startsWith(RemoteLinuxRunConfiguration::IdPrefix)) return false; if (mode == NormalRunMode) return true; const RemoteLinuxRunConfiguration * const remoteRunConfig = qobject_cast<RemoteLinuxRunConfiguration *>(runConfiguration); if (mode == DebugRunMode) { IDevice::ConstPtr dev = DeviceKitInformation::device(runConfiguration->target()->kit()); if (dev.isNull()) return false; return remoteRunConfig->portsUsedByDebuggers() <= dev->freePorts().count(); } return true; }
RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, Core::Id mode, QString *errorMessage) { Q_ASSERT(canRun(runConfig, mode)); IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(runConfig); Q_ASSERT(rc); Target *target = runConfig->target(); QTC_ASSERT(target, return 0); RunControl *res = 0; Core::Id devId = DeviceKitInformation::deviceId(rc->target()->kit()); // The device can only run an application at a time, if an app is running stop it. if (m_activeRunControls.contains(devId)) { if (QPointer<RunControl> activeRunControl = m_activeRunControls[devId]) activeRunControl->stop(); m_activeRunControls.remove(devId); } if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) res = new Ios::Internal::IosRunControl(rc); else if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(runConfig, mode); QTC_ASSERT(runControl, return 0); IDevice::ConstPtr device = DeviceKitInformation::device(target->kit()); if (device.isNull()) return 0; auto iosRunConfig = qobject_cast<IosRunConfiguration *>(runConfig); StandardRunnable runnable; runnable.executable = iosRunConfig->localExecutable().toUserOutput(); runnable.commandLineArguments = iosRunConfig->commandLineArguments(); AnalyzerConnection connection; connection.analyzerHost = QLatin1String("localhost"); runControl->setRunnable(runnable); runControl->setConnection(connection); runControl->setDisplayName(iosRunConfig->applicationName()); (void) new IosAnalyzeSupport(iosRunConfig, runControl, false, true); return runControl; }
void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid, const Ios::IosToolHandler::Dict &info) { DeviceManager *devManager = DeviceManager::instance(); Core::Id baseDevId(Constants::IOS_DEVICE_ID); Core::Id devType(Constants::IOS_DEVICE_TYPE); Core::Id devId = baseDevId.withSuffix(uid); IDevice::ConstPtr dev = devManager->find(devId); bool skipUpdate = false; IosDevice *newDev = 0; if (!dev.isNull() && dev->type() == devType) { const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data()); if (iosDev->m_extraInfo == info) { skipUpdate = true; newDev = const_cast<IosDevice *>(iosDev); } else { newDev = new IosDevice(*iosDev); } } else { newDev = new IosDevice(uid); } if (!skipUpdate) { QString devNameKey = QLatin1String("deviceName"); if (info.contains(devNameKey)) newDev->setDisplayName(info.value(devNameKey)); newDev->m_extraInfo = info; qCDebug(detectLog) << "updated info of ios device " << uid; dev = IDevice::ConstPtr(newDev); devManager->addDevice(dev); } QLatin1String devStatusKey = QLatin1String("developerStatus"); if (info.contains(devStatusKey)) { QString devStatus = info.value(devStatusKey); if (devStatus == QLatin1String("Development")) { devManager->setDeviceState(newDev->id(), IDevice::DeviceReadyToUse); m_userModeDeviceIds.removeOne(uid); } else { devManager->setDeviceState(newDev->id(), IDevice::DeviceConnected); bool shouldIgnore = newDev->m_ignoreDevice; newDev->m_ignoreDevice = true; if (devStatus == QLatin1String("*off*")) { if (!shouldIgnore && !IosConfigurations::ignoreAllDevices()) { QMessageBox mBox; mBox.setText(tr("An iOS device in user mode has been detected.")); mBox.setInformativeText(tr("Do you want to see how to set it up for development?")); mBox.setStandardButtons(QMessageBox::NoAll | QMessageBox::No | QMessageBox::Yes); mBox.setDefaultButton(QMessageBox::Yes); int ret = mBox.exec(); switch (ret) { case QMessageBox::Yes: Core::HelpManager::handleHelpRequest( QLatin1String("qthelp://org.qt-project.qtcreator/doc/creator-developing-ios.html")); break; case QMessageBox::No: break; case QMessageBox::NoAll: IosConfigurations::setIgnoreAllDevices(true); break; default: break; } } } if (!m_userModeDeviceIds.contains(uid)) m_userModeDeviceIds.append(uid); m_userModeDevicesTimer.start(); } } }