void CommandTableModel::buildFromXml(XmlElement *root) { if (root->getTagName().compare("settings") != 0) return; removeAllRows(); XmlElement* setting = root->getFirstChildElement(); while ((setting) && (m_commandMap)) { if (setting->hasAttribute("controller")) { MIDI_Message cc(setting->getIntAttribute("channel"), setting->getIntAttribute("controller"), true); addRow(cc.channel, cc.controller, true); // older versions of MIDI2LR stored the index of the string, so we should attempt to parse this as well if (setting->getIntAttribute("command", -1) != -1) { m_commandMap->addCommandforMessage(setting->getIntAttribute("command"), cc); } else { m_commandMap->addCommandforMessage(setting->getStringAttribute("command_string"), cc); } } else if (setting->hasAttribute("note")) { MIDI_Message note(setting->getIntAttribute("channel"), setting->getIntAttribute("note"), false); addRow(note.channel, note.pitch, false); // older versions of MIDI2LR stored the index of the string, so we should attempt to parse this as well if (setting->getIntAttribute("command", -1) != -1) { m_commandMap->addCommandforMessage(setting->getIntAttribute("command"), note); } else { m_commandMap->addCommandforMessage(setting->getStringAttribute("command_string"), note); } } setting = setting->getNextElement(); } }
void GUI::ClientListComponent::readClientDetailsFromXML() { if(File(csplayerxmlFilePath).exists())//if File CsPlayer.scp is exist { File f=File(csplayerxmlFilePath); XmlDocument xmlDoc(f); // Csplayer to take document of XMLDocument ScopedPointer<XmlElement> Csplayer; Csplayer = xmlDoc.getDocumentElement(); if(Csplayer) //if CsPlayer.scp file is not blank.... { XmlElement * clientElement = Csplayer->getChildByName("Clients")->getChildByName("Client"); while(clientElement) { Configurations::ClientInfo tempClientInfo; tempClientInfo.fromXML(clientElement); // Add clientInformation into Array clientInfoArray.add(tempClientInfo); clientElement = clientElement->getNextElement(); } clientListBox->updateContent(); } } }
bool OwlNestSettings::downloadFromServer(CommandID commandID) { String nodeString, optionString, warningString; PropertySet* props = ApplicationConfiguration::getApplicationProperties(); switch (commandID){ case ApplicationCommands::checkForFirmwareUpdates: warningString = "Beware that this procedure can make your OWL unresponsive!"; nodeString = "firmwares"; optionString = props->getValue("firmware-dfu-options"); break; case ApplicationCommands::checkForBootloaderUpdates: warningString = "Beware that this procedure can brick your OWL!"; nodeString = "bootloaders"; optionString = props->getValue("bootloader-dfu-options"); break; default: return false; } String xmlFilename ("updates.xml"); URL url(props->getValue("owl-updates-dir-url")+xmlFilename); ScopedPointer<XmlElement> xmlUpdates; if(url.isWellFormed()) xmlUpdates = url.readEntireXmlStream(0); if(xmlUpdates == NULL) { AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Connection Error", "Server connection failed"); return false; } XmlElement* filesNode = xmlUpdates->getChildByName(nodeString); StringArray names; XmlElement* child = filesNode->getFirstChildElement(); while(child != nullptr){ names.add(child->getStringAttribute("name")); child = child->getNextElement(); } AlertWindow popup("Download File From Server", "Choose file:", juce::AlertWindow::InfoIcon); popup.addButton("Cancel", 0, juce::KeyPress(), juce::KeyPress()); popup.addButton("Download", 1, juce::KeyPress(), juce::KeyPress()); popup.addComboBox("box", names); if(popup.runModalLoop()==0) return false; popup.setVisible(false); String selectedFilename(popup.getComboBoxComponent("box")->getText()); URL fwUrl(props->getValue("owl-updates-dir-url")+selectedFilename); ScopedPointer<InputStream> strm; strm = fwUrl.createInputStream(0); if(strm == NULL){ AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Connection Error", "File unavailable", "Continue"); return false; } File theTargetFile(ApplicationConfiguration::getApplicationDirectory().getChildFile(selectedFilename)); FileChooser chooser("Save As", theTargetFile, "*.bin"); bool succeeded = false; if(!chooser.browseForFileToSave(true)) return false; theTargetFile = chooser.getResult(); TemporaryFile temp (theTargetFile); ScopedPointer<FileOutputStream> out(temp.getFile().createOutputStream()); if(out != nullptr) { out->writeFromInputStream(*strm, strm->getTotalLength()); out = nullptr; // deletes the stream succeeded = temp.overwriteTargetFileWithTemporary(); } if(!succeeded){ AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "File Error", "Failed to save file", "Continue"); return false; } if(AlertWindow::showOkCancelBox(AlertWindow::QuestionIcon, "Update Device", "Would you like to update your OWL with this binary now? "+warningString, "Yes", "No")) { DBG("pathName"<< theTargetFile.getFullPathName()); DBG("optionString " << optionString); return deviceFirmwareUpdate(theTargetFile, optionString); } return true; }