@@ -34,12 +34,14 @@ | |||
#include "CarlaMIDI.h" | |||
#include "jackbridge/JackBridge.hpp" | |||
#include "juce_core.h" | |||
#include <QtCore/QDir> | |||
#include <QtCore/QFile> | |||
#include <QtCore/QFileInfo> | |||
#include <QtCore/QTextStream> | |||
#include <QtXml/QDomNode> | |||
using juce::File; | |||
using juce::MemoryOutputStream; | |||
using juce::ScopedPointer; | |||
using juce::String; | |||
using juce::XmlDocument; | |||
using juce::XmlElement; | |||
// ----------------------------------------------------------------------- | |||
@@ -1038,9 +1040,9 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
} | |||
} | |||
QFile file(bridgeBinary.buffer()); | |||
File file(bridgeBinary.buffer()); | |||
if (! file.exists()) | |||
if (! file.existsAsFile()) | |||
bridgeBinary.clear(); | |||
} | |||
@@ -1054,9 +1056,9 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
else if (btype == BINARY_WIN32) | |||
{ | |||
// fallback to dssi-vst | |||
QFileInfo fileInfo(filename); | |||
File file(filename); | |||
CarlaString label2(fileInfo.fileName().toUtf8().constData()); | |||
CarlaString label2(file.getFullPathName().toRawUTF8()); | |||
label2.replace(' ', '*'); | |||
CarlaPlugin::Initializer init2 = { | |||
@@ -1069,7 +1071,7 @@ bool CarlaEngine::addPlugin(const BinaryType btype, const PluginType ptype, cons | |||
}; | |||
char* const oldVstPath(getenv("VST_PATH")); | |||
carla_setenv("VST_PATH", fileInfo.absoluteDir().absolutePath().toUtf8().constData()); | |||
carla_setenv("VST_PATH", file.getParentDirectory().getFullPathName().toRawUTF8()); | |||
plugin = CarlaPlugin::newDSSI(init2); | |||
@@ -1525,28 +1527,11 @@ bool CarlaEngine::loadFile(const char* const filename) | |||
CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #1)"); | |||
carla_debug("CarlaEngine::loadFile(\"%s\")", filename); | |||
QFileInfo fileInfo(filename); | |||
File file(filename); | |||
CARLA_SAFE_ASSERT_RETURN_ERR(file.existsAsFile(), "Requested file does not exist or is not a readable file"); | |||
if (! fileInfo.exists()) | |||
{ | |||
setLastError("File does not exist"); | |||
return false; | |||
} | |||
if (! fileInfo.isFile()) | |||
{ | |||
setLastError("Not a file"); | |||
return false; | |||
} | |||
if (! fileInfo.isReadable()) | |||
{ | |||
setLastError("File is not readable"); | |||
return false; | |||
} | |||
CarlaString baseName(fileInfo.baseName().toUtf8().constData()); | |||
CarlaString extension(fileInfo.suffix().toLower().toUtf8().constData()); | |||
CarlaString baseName(file.getFileName().toRawUTF8()); | |||
CarlaString extension(file.getFileExtension().toRawUTF8()); | |||
extension.toLower(); | |||
// ------------------------------------------------------------------- | |||
@@ -1656,32 +1641,35 @@ bool CarlaEngine::loadProject(const char* const filename) | |||
CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #2)"); | |||
carla_debug("CarlaEngine::loadProject(\"%s\")", filename); | |||
QFile file(filename); | |||
if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) | |||
return false; | |||
File file(filename); | |||
CARLA_SAFE_ASSERT_RETURN_ERR(file.existsAsFile(), "Requested file does not exist or is not a readable file"); | |||
QDomDocument xml; | |||
xml.setContent(file.readAll()); | |||
file.close(); | |||
XmlDocument xml(file); | |||
ScopedPointer<XmlElement> xmlElement(xml.getDocumentElement(true)); | |||
CARLA_SAFE_ASSERT_RETURN_ERR(xmlElement != nullptr, "Failed to parse project file"); | |||
QDomNode xmlNode(xml.documentElement()); | |||
const String& xmlType(xmlElement->getTagName()); | |||
const bool isPreset(xmlType.equalsIgnoreCase("carla-preset")); | |||
const bool isPreset(xmlNode.toElement().tagName().compare("carla-preset", Qt::CaseInsensitive) == 0); | |||
if (xmlNode.toElement().tagName().compare("carla-project", Qt::CaseInsensitive) != 0 && ! isPreset) | |||
if (! (xmlType.equalsIgnoreCase("carla-project") || isPreset)) | |||
{ | |||
setLastError("Not a valid Carla project or preset file"); | |||
return false; | |||
} | |||
// completely load file | |||
xmlElement = xml.getDocumentElement(false); | |||
CARLA_SAFE_ASSERT_RETURN_ERR(xmlElement != nullptr, "Failed to completely parse project file"); | |||
// handle plugins first | |||
for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling()) | |||
for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) | |||
{ | |||
if (isPreset || node.toElement().tagName().compare("plugin", Qt::CaseInsensitive) == 0) | |||
const String& tagName(elem->getTagName()); | |||
if (isPreset || tagName.equalsIgnoreCase("plugin")) | |||
{ | |||
StateSave stateSave; | |||
stateSave.fillFromXmlNode(isPreset ? xmlNode : node); | |||
stateSave.fillFromXmlElement(isPreset ? xmlElement.get() : elem); | |||
callback(ENGINE_CALLBACK_IDLE, 0, 0, 0, 0.0f, nullptr); | |||
@@ -1725,30 +1713,34 @@ bool CarlaEngine::loadProject(const char* const filename) | |||
return true; | |||
} | |||
// now connections | |||
for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling()) | |||
// now handle connections | |||
for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) | |||
{ | |||
if (node.toElement().tagName().compare("patchbay", Qt::CaseInsensitive) == 0) | |||
const String& tagName(elem->getTagName()); | |||
if (tagName.equalsIgnoreCase("patchbay")) | |||
{ | |||
CarlaString sourcePort, targetPort; | |||
for (QDomNode patchNode = node.firstChild(); ! patchNode.isNull(); patchNode = patchNode.nextSibling()) | |||
for (XmlElement* patchElem = elem->getFirstChildElement(); patchElem != nullptr; patchElem = patchElem->getNextElement()) | |||
{ | |||
const String& patchTag(patchElem->getTagName()); | |||
sourcePort.clear(); | |||
targetPort.clear(); | |||
if (patchNode.toElement().tagName().compare("connection", Qt::CaseInsensitive) != 0) | |||
if (! patchTag.equalsIgnoreCase("connection")) | |||
continue; | |||
for (QDomNode connNode = patchNode.firstChild(); ! connNode.isNull(); connNode = connNode.nextSibling()) | |||
for (XmlElement* connElem = patchElem->getFirstChildElement(); connElem != nullptr; connElem = connElem->getNextElement()) | |||
{ | |||
const QString tag(connNode.toElement().tagName()); | |||
const QString text(connNode.toElement().text().trimmed()); | |||
const String& tag(connElem->getTagName()); | |||
const String text(connElem->getAllSubText().trim()); | |||
if (tag.compare("source", Qt::CaseInsensitive) == 0) | |||
sourcePort = text.toUtf8().constData(); | |||
else if (tag.compare("target", Qt::CaseInsensitive) == 0) | |||
targetPort = text.toUtf8().constData(); | |||
if (tag.equalsIgnoreCase("source")) | |||
sourcePort = text.toRawUTF8(); | |||
else if (tag.equalsIgnoreCase("target")) | |||
targetPort = text.toRawUTF8(); | |||
} | |||
if (sourcePort.isNotEmpty() && targetPort.isNotEmpty()) | |||
@@ -1767,12 +1759,7 @@ bool CarlaEngine::saveProject(const char* const filename) | |||
CARLA_SAFE_ASSERT_RETURN_ERR(filename != nullptr && filename[0] != '\0', "Invalid filename (err #3)"); | |||
carla_debug("CarlaEngine::saveProject(\"%s\")", filename); | |||
QFile file(filename); | |||
if (! file.open(QIODevice::WriteOnly | QIODevice::Text)) | |||
return false; | |||
QTextStream out(&file); | |||
MemoryOutputStream out; | |||
out << "<?xml version='1.0' encoding='UTF-8'?>\n"; | |||
out << "<!DOCTYPE CARLA-PROJECT>\n"; | |||
out << "<CARLA-PROJECT VERSION='2.0'>\n"; | |||
@@ -1842,8 +1829,13 @@ bool CarlaEngine::saveProject(const char* const filename) | |||
out << "</CARLA-PROJECT>\n"; | |||
file.close(); | |||
return true; | |||
File file(filename); | |||
if (file.replaceWithData(out.getData(), out.getDataSize())) | |||
return true; | |||
setLastError("Failed to write file"); | |||
return false; | |||
} | |||
// ----------------------------------------------------------------------- | |||
@@ -26,7 +26,7 @@ | |||
#include "jackbridge/JackBridge.hpp" | |||
#include "jackey.h" | |||
#include <QtCore/QStringList> | |||
#include "juce_core.h" | |||
#ifdef __SSE2_MATH__ | |||
# include <xmmintrin.h> | |||
@@ -34,6 +34,9 @@ | |||
#define URI_CANVAS_ICON "http://kxstudio.sf.net/ns/canvas/icon" | |||
using juce::String; | |||
using juce::StringArray; | |||
CARLA_BACKEND_START_NAMESPACE | |||
#if 0 | |||
@@ -1862,11 +1865,11 @@ private: | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(ourName != nullptr && ourName[0] != '\0',); | |||
QStringList parsedGroups; | |||
StringArray parsedGroups; | |||
// add our client first | |||
{ | |||
parsedGroups.append(QString(ourName)); | |||
parsedGroups.add(String(ourName)); | |||
GroupNameToId groupNameToId; | |||
groupNameToId.setData(++fUsedGroups.lastId, ourName); | |||
@@ -1899,9 +1902,9 @@ private: | |||
CARLA_SAFE_ASSERT_CONTINUE(found); | |||
QString qGroupName(groupName.buffer()); | |||
String jGroupName(groupName.buffer()); | |||
if (parsedGroups.contains(qGroupName)) | |||
if (parsedGroups.contains(jGroupName)) | |||
{ | |||
groupId = fUsedGroups.getGroupId(groupName); | |||
CARLA_SAFE_ASSERT_CONTINUE(groupId > 0); | |||
@@ -1909,7 +1912,7 @@ private: | |||
else | |||
{ | |||
groupId = ++fUsedGroups.lastId; | |||
parsedGroups.append(qGroupName); | |||
parsedGroups.add(jGroupName); | |||
int pluginId = -1; | |||
PatchbayIcon icon = (jackPortFlags & JackPortIsPhysical) ? PATCHBAY_ICON_HARDWARE : PATCHBAY_ICON_APPLICATION; | |||
@@ -34,8 +34,13 @@ | |||
#include "CarlaExternalUI.hpp" | |||
#include "CarlaNative.hpp" | |||
#include <QtCore/QTextStream> | |||
#include <QtXml/QDomNode> | |||
#include "juce_core.h" | |||
using juce::MemoryOutputStream; | |||
using juce::ScopedPointer; | |||
using juce::String; | |||
using juce::XmlDocument; | |||
using juce::XmlElement; | |||
CARLA_BACKEND_START_NAMESPACE | |||
@@ -1288,8 +1293,7 @@ protected: | |||
char* getState() const | |||
{ | |||
QString string; | |||
QTextStream out(&string); | |||
MemoryOutputStream out; | |||
out << "<?xml version='1.0' encoding='UTF-8'?>\n"; | |||
out << "<!DOCTYPE CARLA-PROJECT>\n"; | |||
out << "<CARLA-PROJECT VERSION='2.0'>\n"; | |||
@@ -1323,30 +1327,32 @@ protected: | |||
out << "</CARLA-PROJECT>\n"; | |||
return strdup(string.toUtf8().constData()); | |||
return strdup(out.toString().toRawUTF8()); | |||
} | |||
void setState(const char* const data) | |||
{ | |||
QDomDocument xml; | |||
xml.setContent(QString(data)); | |||
const String text(data); | |||
XmlDocument xml(text); | |||
QDomNode xmlNode(xml.documentElement()); | |||
ScopedPointer<XmlElement> xmlElement(xml.getDocumentElement(true)); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr,); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement->getTagName().equalsIgnoreCase("carla-project"),); | |||
if (xmlNode.toElement().tagName().compare("carla-project", Qt::CaseInsensitive) != 0) | |||
{ | |||
carla_stderr2("Not a valid Carla project"); | |||
return; | |||
} | |||
// completely load file | |||
xmlElement = xml.getDocumentElement(false); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr,); | |||
//bool pluginsAdded = false; | |||
for (QDomNode node = xmlNode.firstChild(); ! node.isNull(); node = node.nextSibling()) | |||
for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) | |||
{ | |||
if (node.toElement().tagName().compare("plugin", Qt::CaseInsensitive) == 0) | |||
const String& tagName(elem->getTagName()); | |||
if (tagName.equalsIgnoreCase("plugin")) | |||
{ | |||
StateSave stateSave; | |||
stateSave.fillFromXmlNode(node); | |||
stateSave.fillFromXmlElement(elem); | |||
CARLA_SAFE_ASSERT_CONTINUE(stateSave.type != nullptr); | |||
@@ -60,7 +60,7 @@ debug: | |||
# -------------------------------------------------------------- | |||
CarlaEngine.cpp.o: CarlaEngine.cpp $(CARLA_ENGINE_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -c -o $@ | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineInternal.cpp.o: CarlaEngineInternal.cpp $(CARLA_ENGINE_INTERNAL_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
@@ -72,7 +72,7 @@ CarlaEngineThread.cpp.o: CarlaEngineThread.cpp $(CARLA_ENGINE_THREAD_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineJack.cpp.o: CarlaEngineJack.cpp $(CARLA_ENGINE_JACK_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineRtAudio.cpp.o: CarlaEngineRtAudio.cpp $(CARLA_ENGINE_RTAUDIO_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(RTAUDIO_FLAGS) $(RTMIDI_FLAGS) -c -o $@ | |||
@@ -81,9 +81,9 @@ CarlaEngineJuce.cpp.o: CarlaEngineJuce.cpp $(CARLA_ENGINE_JUCE_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineNative.cpp.o: CarlaEngineNative.cpp $(CARLA_ENGINE_NATIVE_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -c -o $@ | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@ | |||
CarlaEngineNative.cpp.exp.o: CarlaEngineNative.cpp $(CARLA_ENGINE_NATIVE_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -DCARLA_PLUGIN_EXPORT -c -o $@ | |||
$(CXX) $< $(BUILD_CXX_FLAGS) -DCARLA_PLUGIN_EXPORT -c -o $@ | |||
# -------------------------------------------------------------- |
@@ -24,9 +24,17 @@ | |||
#include <ctime> | |||
#include <QtCore/QFile> | |||
#include <QtCore/QTextStream> | |||
#include <QtXml/QDomNode> | |||
// FIXME | |||
#include <QtCore/QByteArray> | |||
#include "juce_core.h" | |||
using juce::File; | |||
using juce::MemoryOutputStream; | |||
using juce::ScopedPointer; | |||
using juce::String; | |||
using juce::XmlDocument; | |||
using juce::XmlElement; | |||
CARLA_BACKEND_START_NAMESPACE | |||
@@ -856,20 +864,20 @@ bool CarlaPlugin::saveStateToFile(const char* const filename) | |||
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); | |||
carla_debug("CarlaPlugin::saveStateToFile(\"%s\")", filename); | |||
QFile file(filename); | |||
if (! file.open(QIODevice::WriteOnly | QIODevice::Text)) | |||
return false; | |||
QTextStream out(&file); | |||
MemoryOutputStream out; | |||
out << "<?xml version='1.0' encoding='UTF-8'?>\n"; | |||
out << "<!DOCTYPE CARLA-PRESET>\n"; | |||
out << "<CARLA-PRESET VERSION='2.0'>\n"; | |||
out << getStateSave().toString(); | |||
out << "</CARLA-PRESET>\n"; | |||
file.close(); | |||
return true; | |||
File file(filename); | |||
if (file.replaceWithData(out.getData(), out.getDataSize())) | |||
return true; | |||
pData->engine->setLastError("Failed to write file"); | |||
return false; | |||
} | |||
bool CarlaPlugin::loadStateFromFile(const char* const filename) | |||
@@ -877,25 +885,20 @@ bool CarlaPlugin::loadStateFromFile(const char* const filename) | |||
CARLA_SAFE_ASSERT_RETURN(filename != nullptr && filename[0] != '\0', false); | |||
carla_debug("CarlaPlugin::loadStateFromFile(\"%s\")", filename); | |||
QFile file(filename); | |||
File file(filename); | |||
CARLA_SAFE_ASSERT_RETURN(file.existsAsFile(), false); | |||
if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) | |||
return false; | |||
XmlDocument xml(file); | |||
ScopedPointer<XmlElement> xmlElement(xml.getDocumentElement(true)); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr, false); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement->getTagName().equalsIgnoreCase("carla-preset"), false); | |||
QDomDocument xml; | |||
xml.setContent(file.readAll()); | |||
file.close(); | |||
// completely load file | |||
xmlElement = xml.getDocumentElement(false); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr, false); | |||
QDomNode xmlNode(xml.documentElement()); | |||
if (xmlNode.toElement().tagName().compare("carla-preset", Qt::CaseInsensitive) == 0) | |||
{ | |||
pData->engine->setLastError("Not a valid Carla preset file"); | |||
return false; | |||
} | |||
pData->stateSave.fillFromXmlNode(xmlNode); | |||
loadStateSave(pData->stateSave); | |||
if (pData->stateSave.fillFromXmlElement(xmlElement->getFirstChildElement())) | |||
loadStateSave(pData->stateSave); | |||
return true; | |||
} | |||
@@ -1410,8 +1413,10 @@ void CarlaPlugin::idle() | |||
carla_stdout("Trying to get window..."); | |||
QString uiTitle(QString("%1 (GUI)").arg(pData->name)); | |||
if (CarlaPluginUi::tryTransientWinIdMatch(pData->osc.data.target != nullptr ? pData->osc.thread.getPid() : 0, uiTitle.toUtf8().constData(), pData->engine->getOptions().frontendWinId)) | |||
CarlaString uiTitle(pData->name); | |||
uiTitle += " (GUI)"; | |||
if (CarlaPluginUi::tryTransientWinIdMatch(pData->osc.data.target != nullptr ? pData->osc.thread.getPid() : 0, uiTitle, pData->engine->getOptions().frontendWinId)) | |||
pData->transientTryCounter = 0; | |||
} | |||
@@ -52,7 +52,7 @@ debug: | |||
# -------------------------------------------------------------- | |||
CarlaPlugin.cpp.o: CarlaPlugin.cpp $(CARLA_PLUGIN_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) $(QTXML_FLAGS) -c -o $@ | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ | |||
CarlaPluginInternal.cpp.o: CarlaPluginInternal.cpp $(CARLA_PLUGIN_INTERNAL_CPP_DEPS) | |||
$(CXX) $< $(BUILD_CXX_FLAGS) $(QTCORE_FLAGS) -c -o $@ | |||
@@ -209,9 +209,7 @@ class CarlaScopeTryLocker | |||
public: | |||
CarlaScopeTryLocker(const Mutex& mutex) noexcept | |||
: fMutex(mutex), | |||
fLocked(mutex.tryLock()) | |||
{ | |||
} | |||
fLocked(mutex.tryLock()) {} | |||
~CarlaScopeTryLocker() noexcept | |||
{ | |||
@@ -120,9 +120,7 @@ public: | |||
bool isDataAvailableForReading() const noexcept | |||
{ | |||
CARLA_SAFE_ASSERT_RETURN(fBuffer != nullptr, false); | |||
return (fBuffer->buf != nullptr && fBuffer->head != fBuffer->tail); | |||
return (fBuffer != nullptr && fBuffer->buf != nullptr && fBuffer->head != fBuffer->tail); | |||
} | |||
bool isEmpty() const noexcept | |||
@@ -21,11 +21,11 @@ | |||
#include "CarlaMathUtils.hpp" | |||
#include "CarlaMIDI.h" | |||
#ifdef HAVE_JUCE_LATER | |||
# include "juce_core.h" | |||
#include "juce_core.h" | |||
using juce::String; | |||
using juce::XmlElement; | |||
#else | |||
#if 0 | |||
# include <QtCore/QString> | |||
# include <QtXml/QDomNode> | |||
#endif | |||
@@ -35,7 +35,6 @@ CARLA_BACKEND_START_NAMESPACE | |||
// ----------------------------------------------------------------------- | |||
// xmlSafeString | |||
#ifdef HAVE_JUCE_LATER | |||
static String xmlSafeString(const String& string, const bool toXml) | |||
{ | |||
String newString(string); | |||
@@ -45,7 +44,7 @@ static String xmlSafeString(const String& string, const bool toXml) | |||
else | |||
return newString.replace("<","<").replace(">",">").replace("'","'").replace(""","\"").replace("&","&"); | |||
} | |||
#else | |||
#if 0 | |||
static QString xmlSafeString(const QString& string, const bool toXml) | |||
{ | |||
QString newString(string); | |||
@@ -60,12 +59,11 @@ static QString xmlSafeString(const QString& string, const bool toXml) | |||
// ----------------------------------------------------------------------- | |||
// xmlSafeStringCharDup | |||
#ifdef HAVE_JUCE_LATER | |||
static const char* xmlSafeStringCharDup(const String& string, const bool toXml) | |||
{ | |||
return carla_strdup(xmlSafeString(string, toXml).toRawUTF8()); | |||
} | |||
#else | |||
#if 0 | |||
static const char* xmlSafeStringCharDup(const QString& string, const bool toXml) | |||
{ | |||
return carla_strdup(xmlSafeString(string, toXml).toUtf8().constData()); | |||
@@ -216,16 +214,15 @@ void StateSave::clear() noexcept | |||
// ----------------------------------------------------------------------- | |||
// fillFromXmlElement | |||
#ifdef HAVE_JUCE_LATER | |||
void StateSave::fillFromXmlElement(const XmlElement* const xmlElement) | |||
bool StateSave::fillFromXmlElement(const XmlElement* const xmlElement) | |||
{ | |||
clear(); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr, false); | |||
CARLA_SAFE_ASSERT_RETURN(xmlElement != nullptr,); | |||
clear(); | |||
for (XmlElement* elem = xmlElement->getFirstChildElement(); elem != nullptr; elem = elem->getNextElement()) | |||
{ | |||
String tagName(elem->getTagName()); | |||
const String& tagName(elem->getTagName()); | |||
// --------------------------------------------------------------- | |||
// Info | |||
@@ -404,8 +401,10 @@ void StateSave::fillFromXmlElement(const XmlElement* const xmlElement) | |||
} | |||
} | |||
} | |||
return true; | |||
} | |||
#else | |||
#if 0 | |||
void StateSave::fillFromXmlNode(const QDomNode& xmlNode) | |||
{ | |||
clear(); | |||
@@ -629,7 +628,6 @@ void StateSave::fillFromXmlNode(const QDomNode& xmlNode) | |||
// ----------------------------------------------------------------------- | |||
// fillXmlStringFromStateSave | |||
#ifdef HAVE_JUCE_LATER | |||
String StateSave::toString() const | |||
{ | |||
String content; | |||
@@ -702,15 +700,15 @@ String StateSave::toString() const | |||
dataXml << " <Active>" << (active ? "Yes" : "No") << "</Active>\n"; | |||
if (dryWet != 1.0f) | |||
dataXml << " <DryWet>" << dryWet << "</DryWet>\n"; | |||
dataXml << " <DryWet>" << String(dryWet, 7) << "</DryWet>\n"; | |||
if (volume != 1.0f) | |||
dataXml << " <Volume>" << volume << "</Volume>\n"; | |||
dataXml << " <Volume>" << String(volume, 7) << "</Volume>\n"; | |||
if (balanceLeft != -1.0f) | |||
dataXml << " <Balance-Left>" << balanceLeft << "</Balance-Left>\n"; | |||
dataXml << " <Balance-Left>" << String(balanceLeft, 7) << "</Balance-Left>\n"; | |||
if (balanceRight != 1.0f) | |||
dataXml << " <Balance-Right>" << balanceRight << "</Balance-Right>\n"; | |||
dataXml << " <Balance-Right>" << String(balanceRight, 7) << "</Balance-Right>\n"; | |||
if (panning != 0.0f) | |||
dataXml << " <Panning>" << panning << "</Panning>\n"; | |||
dataXml << " <Panning>" << String(panning, 7) << "</Panning>\n"; | |||
if (ctrlChannel < 0) | |||
dataXml << " <ControlChannel>N</ControlChannel>\n"; | |||
@@ -733,7 +731,7 @@ String StateSave::toString() const | |||
parameterXml << " <Symbol>" << xmlSafeString(stateParameter->symbol, true) << "</Symbol>\n"; | |||
if (stateParameter->isInput) | |||
parameterXml << " <Value>" << stateParameter->value << "</Value>\n"; | |||
parameterXml << " <Value>" << String(stateParameter->value, 15) << "</Value>\n"; | |||
if (stateParameter->midiCC > 0) | |||
{ | |||
@@ -783,7 +781,7 @@ String StateSave::toString() const | |||
{ | |||
customDataXml << " <Value>\n"; | |||
customDataXml << xmlSafeString(stateCustomData->value, true); | |||
customDataXml << " </Value>\n"; | |||
customDataXml << "\n </Value>\n"; | |||
} | |||
else | |||
{ | |||
@@ -809,7 +807,7 @@ String StateSave::toString() const | |||
return content; | |||
} | |||
#else | |||
#if 0 | |||
QString StateSave::toString() const | |||
{ | |||
QString content; | |||
@@ -21,15 +21,10 @@ | |||
#include "CarlaBackend.h" | |||
#include "LinkedList.hpp" | |||
#ifdef HAVE_JUCE_LATER | |||
namespace juce { | |||
class String; | |||
class XmlElement; | |||
} | |||
#else | |||
class QDomNode; | |||
class QString; | |||
#endif | |||
// ----------------------------------------------------------------------- | |||
@@ -101,17 +96,8 @@ struct StateSave { | |||
~StateSave() noexcept; | |||
void clear() noexcept; | |||
#ifdef HAVE_JUCE_LATER | |||
void fillFromXmlElement(const juce::XmlElement* const xmlElement); | |||
#else | |||
void fillFromXmlNode(const QDomNode& xmlNode); | |||
#endif | |||
#ifdef HAVE_JUCE_LATER | |||
bool fillFromXmlElement(const juce::XmlElement* const xmlElement); | |||
juce::String toString() const; | |||
#else | |||
QString toString() const; | |||
#endif | |||
CARLA_DECLARE_NON_COPY_STRUCT(StateSave) | |||
}; | |||