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); }
bool DeviceCheckBuildStep::init(QList<const BuildStep *> &earlierSteps) { Q_UNUSED(earlierSteps); IDevice::ConstPtr device = DeviceKitInformation::device(target()->kit()); if (!device) { Core::Id deviceTypeId = DeviceTypeKitInformation::deviceTypeId(target()->kit()); IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId); if (!factory || !factory->canCreate()) { emit addOutput(tr("No device configured."), BuildStep::ErrorMessageOutput); return false; } QMessageBox msgBox(QMessageBox::Question, tr("Set Up Device"), tr("There is no device set up for this kit. Do you want to add a device?"), QMessageBox::Yes|QMessageBox::No); msgBox.setDefaultButton(QMessageBox::Yes); if (msgBox.exec() == QMessageBox::No) { emit addOutput(tr("No device configured."), BuildStep::ErrorMessageOutput); return false; } IDevice::Ptr newDevice = factory->create(deviceTypeId); if (newDevice.isNull()) { emit addOutput(tr("No device configured."), BuildStep::ErrorMessageOutput); return false; } DeviceManager *dm = DeviceManager::instance(); dm->addDevice(newDevice); DeviceKitInformation::setDevice(target()->kit(), newDevice); } return true; }
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(); } } }
//-------------------------------------------------------------- void oscReceiver::update() { DeviceManager* pDeviceManager = Globals::instance()->mp_deviceManager; if (hasWaitingMessages()) { while(getNextMessage(&m_oscMessage)) { int indexArg = 0; if (m_oscMessage.getAddress() == OSC_ADDRESS_SET_DEVICE_PROP) { Device* pDevice = pDeviceManager->getDeviceById( m_oscMessage.getArgAsString(indexArg++) ); if (pDevice) { // Property string propName = m_oscMessage.getArgAsString(indexArg++); if (propName == "volMax") { pDevice->setSoundInputVolumeMaxOSC( m_oscMessage.getArgAsFloat(indexArg) ); } else if (propName == "volHistorySize") { pDevice->setSoundInputVolHistorySizeOSC( m_oscMessage.getArgAsInt32(indexArg) ); } else if (propName == "volHistoryTh") { pDevice->setSoundInputVolHistoryThOSC( m_oscMessage.getArgAsFloat(indexArg) ); } else if (propName == "enableStandbyMode") { pDevice->setEnableStandbyModeOSC( m_oscMessage.getArgAsInt32(indexArg)==1 ? true : false ); } else if (propName == "timeStandby") { //printf("timeStandby = %.3f - ", m_oscMessage.getArgAsFloat(indexArg)); pDevice->setTimeStandbyOSC( m_oscMessage.getArgAsFloat(indexArg) ); } else if (propName == "sampleVolStandby") { pDevice->setSampleVolumeStandbyOSC( m_oscMessage.getArgAsFloat(indexArg) ); } else if (propName == "nbLEDsStandby") { // pDevice->setNbLEDsStandbyOSC( m_oscMessage.getArgAsInt32(indexArg) ); } else if (propName == "speedStandby") { // pDevice->setSpeedStandbyOSC( m_oscMessage.getArgAsFloat(indexArg) ); } } } else if (m_oscMessage.getAddress() == OSC_ADDRESS_SEND_PACKETS) { if (pDeviceManager) { string deviceId = m_oscMessage.getArgAsString(indexArg++); Device* pDevice = pDeviceManager->getDeviceById( deviceId ); // Not found, create the device now if (pDevice == 0) { // TODO : type ? -> factory if (Globals::instance()->mp_app->isSimulation == false) { int nbLEDs = m_oscMessage.getNumArgs() - indexArg; // WARNING with this printf("> New Device found ! id=%s, nbLEDs=%d\n", deviceId.c_str(), nbLEDs); DeviceEcho* pDeviceEcho = new DeviceEcho(deviceId, nbLEDs, 4.0f/float(nbLEDs-1)); pDeviceEcho->setupSenderOSC(m_oscMessage.getRemoteIp(), 1235); pDeviceEcho->loadXML("Config/devices/"); // Add device to list pDeviceManager->addDevice(pDeviceEcho); // TEMP / TODO : attach to surface main if (Globals::instance()->mp_app->mp_surfaceMain) Globals::instance()->mp_app->mp_surfaceMain->addDevice(pDeviceEcho); // Create a node in visualisation scene Globals::instance()->mp_app->createDeviceNodeInScene(pDeviceEcho); // Update interface //Globals::instance()->mp_app->guiMarkUpdateLayout(); Globals::instance()->mp_app->guiUpdateListDevices(); Globals::instance()->mp_app->selectDevice(pDeviceEcho->m_id); // TODO : Send configuration parameters to it (if any) } } // Decode new message if (pDevice) { pDevice->onReceivePacketBegin(); int nbPackets = m_oscMessage.getNumArgs() - indexArg; // TODO : Be careful with this for (int i=0;i<nbPackets;i++) { m_packetTemp.m_volume = m_oscMessage.getArgAsFloat(indexArg++); // TODO : Other arguments to decode here // Send to device pDevice->onReceivePacket(&m_packetTemp); } pDevice->onReceivePacketEnd(); // Get the surface of device and update animation Surface* pSurface = Globals::instance()->mp_app->getSurfaceForDevice(pDevice); if (pSurface){ pSurface->onNewPacket( pDevice->getLastPacket(), pDevice->m_id ); } } } } // New Device plugged // printf("osc %s - %d arguments\n", m_oscMessage.getAddress().c_str(), m_oscMessage.getNumArgs()); // New Device event } } }