コード例 #1
0
void GUI::ClientListComponent::writeClientDetailsToXML()
{
	File f=File(csplayerxmlFilePath);
	XmlDocument xmlDoc(f);
	//Csplayer to take document of XMLDocument
	ScopedPointer<XmlElement>  Csplayer;
	Csplayer=xmlDoc.getDocumentElement();
	
	if(File(csplayerxmlFilePath).exists())//if csPlayer.scp is exist.....
		 if(Csplayer)//if CsPlayer.scp is not blank....
			Csplayer->removeChildElement(Csplayer->getChildByName("Clients"), true);

	Csplayer=new XmlElement("CsPlayer");
	XmlElement  * clientElement =new XmlElement("Clients");
	Csplayer->addChildElement(clientElement);
	for(int row = 0; row < clientInfoArray.size(); row++)
	{
		Configurations::ClientInfo  tempClientInfo;
		tempClientInfo = clientInfoArray.getReference (row);
		XmlElement * clientNode = new XmlElement ("Client");
		tempClientInfo.toXML(clientNode);
		
		Csplayer->getChildByName("Clients")->addChildElement(clientNode);
	}
	Csplayer->writeToFile(File::getCurrentWorkingDirectory().getFullPathName() + File::separatorString + "csPlayer.scp", String::empty);	
}
コード例 #2
0
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();
		}
	}
}
コード例 #3
0
ファイル: PluginProcessor.cpp プロジェクト: nimmen/scopesync
void PluginProcessor::setStateInformation(const void* data, int sizeInBytes)
{
    // Restore parameters from memory block whose contents will have been 
    // created by the getStateInformation() call.
    ScopedPointer<XmlElement> root = getXmlFromBinary(data, sizeInBytes);

	DBG("PluginProcessor::getStateInformation - Retrieving XML: " + root->createDocument(""));

    if (root)
    {
        // Squirrel this data away, in case we need to reload it, e.g. after
        // recreating the device parameters
        if (root->getChildByName("parametervalues"))
        {
            scopeSync->getParameterController()->storeParameterValues(*(root->getChildByName("parametervalues")));
            scopeSync->getParameterController()->restoreParameterValues();
        }
        
        if (root->getChildByName("configurationfilepath"))
        {
            String configurationFilePath = root->getChildByName("configurationfilepath")->getAllSubText();

            scopeSync->changeConfiguration(configurationFilePath);
        }

		if (root->getChildByName("oscuid"))
        {
            int oscUID = root->getChildByName("oscuid")->getAllSubText().getIntValue();

            scopeSync->getParameterController()->getParameterByScopeCode("osc")->setUIValue(static_cast<float>(oscUID));
        }
    }
    else
    {
        DBG("PluginProcessor::setStateInformation - Could not restore XML");
    }
}
コード例 #4
0
ファイル: OwlNestSettings.cpp プロジェクト: aaptel/OwlNest
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;
}