Roll back TONE3000 direct download (not ready for prime time); add direct link to TONE3000 downloads from File Property dialog.

This commit is contained in:
Robin E. R. Davies
2025-06-30 23:54:25 -04:00
parent 3bf1a667c0
commit e092aed47b
13 changed files with 586 additions and 67 deletions
+19
View File
@@ -3038,3 +3038,22 @@ void PiPedalModel::SetPedalboardItemTitle(int64_t instanceId, const std::string
this->SetPresetChanged(-1, true);
this->FirePedalboardChanged(-1, false);
}
void PiPedalModel::SetTone3000Auth(const std::string &apiKey)
{
std::lock_guard<std::recursive_mutex> lock(mutex);
storage.SetTone3000Auth(apiKey);
std::vector<IPiPedalModelSubscriber::ptr> t{subscribers.begin(), subscribers.end()};
bool hasAuth = apiKey != "";
for (auto &subscriber : t)
{
subscriber->OnTone3000AuthChanged(hasAuth);
}
}
bool PiPedalModel::HasTone3000Auth() const
{
return storage.GetTone3000Auth() != "";
}
+6
View File
@@ -96,6 +96,7 @@ namespace pipedal
virtual void OnHasWifiChanged(bool hasWifi) = 0;
virtual void OnAlsaSequencerConfigurationChanged(const AlsaSequencerConfiguration &alsaSequencerConfiguration) = 0;
virtual void Close() = 0;
virtual void OnTone3000AuthChanged(bool value) = 0;
};
@@ -266,6 +267,7 @@ namespace pipedal
void CheckForResourceInitialization(Pedalboard &pedalboard);
UiFileProperty::ptr FindLoadedPatchProperty(int64_t instanceId,const std::string&patchPropertyUri);
public:
PiPedalModel();
virtual ~PiPedalModel();
@@ -479,6 +481,10 @@ namespace pipedal
int32_t to);
void SetPedalboardItemTitle(int64_t instanceId, const std::string &title);
void SetTone3000Auth(const std::string &apiKey);
bool HasTone3000Auth() const;
};
} // namespace pipedal.
+8
View File
@@ -1416,6 +1416,10 @@ public:
pReader->read(&instanceId);
uint64_t result = model.DeleteBank(this->clientId, instanceId);
this->Reply(replyTo, "deleteBankItem", result);
} else if (message == "getHasTone3000Auth")
{
bool result = model.HasTone3000Auth();
this->Reply(replyTo, "getHasTone3000Auth", result);
}
else if (message == "renameBank")
{
@@ -1863,6 +1867,10 @@ private:
{
}
}
virtual void OnTone3000AuthChanged(bool value)
{
Send("onTone3000AuthChanged", value);
}
virtual void OnErrorMessage(const std::string &message)
{
+72 -23
View File
@@ -254,6 +254,7 @@ void Storage::Initialize()
LoadPluginPresetIndex();
LoadBankIndex();
LoadCurrentBank();
LoadTone3000Auth();
try
{
LoadChannelSelection();
@@ -311,6 +312,11 @@ std::filesystem::path Storage::GetCurrentPresetPath() const
return this->dataRoot / "currentPreset.json";
}
std::filesystem::path Storage::GetTone3000AuthPath() const
{
return this->dataRoot / "tone3000.json";
}
std::filesystem::path Storage::GetChannelSelectionFileName()
{
return this->dataRoot / "JackChannelSelection.json";
@@ -741,34 +747,35 @@ JackChannelSelection Storage::GetJackChannelSelection(const JackConfiguration &j
return jackChannelSelection.RemoveInvalidChannels(jackConfiguration);
}
static AlsaSequencerConfiguration MigrateRawMidiToAlsaSequencer(std::vector<AlsaMidiDeviceInfo> &selectedDevices)
{
AlsaSequencerConfiguration result;
try {
auto sequencerPorts = AlsaSequencer::EnumeratePorts();
try
{
auto sequencerPorts = AlsaSequencer::EnumeratePorts();
// Prepare Migrate raw MIDI devices to ALSA sequencer ports.
for (auto i = selectedDevices.begin(); i != selectedDevices.end(); ++i)
{
if (i->name_.starts_with("hw:")) {
for (const auto &port: sequencerPorts)
if (i->name_.starts_with("hw:"))
{
for (const auto &port : sequencerPorts)
{
if (i->name_ == port.rawMidiDevice)
{
result.connections().push_back(
AlsaSequencerPortSelection(port.id, port.name,port.displaySortOrder)
);
AlsaSequencerPortSelection(port.id, port.name, port.displaySortOrder));
break;
}
}
}
}
} catch (const std::exception&e) {
}
catch (const std::exception &e)
{
Lv2Log::error(SS("Failed to migrate MIDI settings. " << e.what()));
// ick.
// ick.
}
return result;
}
@@ -790,23 +797,25 @@ void Storage::LoadAlsaSequencerConfiguration()
{
Lv2Log::error("I/O error reading %s: %s", fileName.c_str(), e.what());
}
} else {
}
else
{
// migrate legacy settings from JackConfiguration?
if (this->isJackChannelSelectionValid)
if (this->isJackChannelSelectionValid)
{
this->alsaSequencerConfiguration =
this->alsaSequencerConfiguration =
MigrateRawMidiToAlsaSequencer(
this->jackChannelSelection.LegacyGetInputMidiDevices());
this->jackChannelSelection.LegacyGetInputMidiDevices().clear(); // let them be clear, the next it gets updated.
} else {
}
else
{
// no legacy settings, so just create a default configuration.
this->alsaSequencerConfiguration = AlsaSequencerConfiguration();
}
SaveAlsaSequencerConfiguration();
}
}
void Storage::SaveAlsaSequencerConfiguration()
{
@@ -814,7 +823,7 @@ void Storage::SaveAlsaSequencerConfiguration()
try
{
pipedal::ofstream_synced s(fileName);
pipedal::ofstream_synced s(fileName);
json_writer writer(s);
writer.write(this->alsaSequencerConfiguration);
}
@@ -822,7 +831,6 @@ void Storage::SaveAlsaSequencerConfiguration()
{
Lv2Log::error("I/O error writing %s: %s", fileName.c_str(), e.what());
}
}
void Storage::SetAlsaSequencerConfiguration(const AlsaSequencerConfiguration &alsaSequencerConfiguration)
@@ -836,7 +844,6 @@ AlsaSequencerConfiguration Storage::GetAlsaSequencerConfiguration() const
return this->alsaSequencerConfiguration;
}
void Storage::LoadChannelSelection()
{
auto fileName = this->GetChannelSelectionFileName();
@@ -861,7 +868,7 @@ void Storage::SaveChannelSelection()
try
{
// replaced with AlsaSequencerConfiguration. Delete legacy data.
this->jackChannelSelection.LegacyGetInputMidiDevices().clear();
this->jackChannelSelection.LegacyGetInputMidiDevices().clear();
pipedal::ofstream_synced s(fileName);
json_writer writer(s, false);
writer.write(this->jackChannelSelection);
@@ -1849,12 +1856,14 @@ static void AddTracksToResult(
}
const auto &path = dir_entry.path();
auto name = path.filename().string();
try {
try
{
if (dir_entry.is_directory())
{
resultFiles.push_back(FileEntry{path, name, true, dir_entry.is_symlink()});
}
} catch (const std::exception &e)
}
catch (const std::exception &e)
{
Lv2Log::warning(SS("Failed to add directory entry: " << path.string() << " - " << e.what()));
}
@@ -1903,7 +1912,6 @@ static void AddTracksToResult(
throw std::logic_error(
SS("AddTracksToResult failed to enumerate audio files. " << rootPath.string() << " - " << error.what()));
}
}
catch (const std::exception &error)
{
@@ -2602,6 +2610,47 @@ const PluginPresetIndex &Storage::GetPluginPresetIndex()
return pluginPresetIndex;
}
void Storage::LoadTone3000Auth()
{
fs::path path = GetTone3000AuthPath();
try
{
if (!fs::exists(path))
{
this->tone3000Auth = "";
return;
}
std::ifstream s(path);
json_reader reader(s);
reader.read(&(this->tone3000Auth));
}
catch (const std::exception &e)
{
Lv2Log::error("Failed to load tone3000Auth: %s", e.what());
}
}
void Storage::SetTone3000Auth(const std::string &apiKey)
{
if (tone3000Auth != apiKey)
{
tone3000Auth = apiKey;
pipedal::ofstream_synced os(this->GetTone3000AuthPath());
if (!os.is_open())
{
Lv2Log::error("Failed to open Tone3000 auth file for writing.");
return;
}
json_writer writer(os);
writer.write(apiKey);
}
}
std::string Storage::GetTone3000Auth() const
{
return tone3000Auth;
}
JSON_MAP_BEGIN(UserSettings)
JSON_MAP_REFERENCE(UserSettings, governor)
JSON_MAP_REFERENCE(UserSettings, showStatusMonitor)
+6
View File
@@ -73,6 +73,7 @@ private:
BankIndex bankIndex;
BankFile currentBank;
PluginPresetIndex pluginPresetIndex;
std::string tone3000Auth;
private:
void FillSampleDirectoryTree(FilePropertyDirectoryTree*node, const std::filesystem::path&directory) const;
@@ -87,6 +88,7 @@ private:
std::filesystem::path GetChannelSelectionFileName();
std::filesystem::path GetAlsaSequencerConfigurationFileName();
std::filesystem::path GetCurrentPresetPath() const;
std::filesystem::path GetTone3000AuthPath() const;
void LoadBankIndex();
void SaveBankIndex();
@@ -254,6 +256,10 @@ public:
const UiFileProperty&uiFileProperty,
bool overwrite = false);
FilePropertyDirectoryTree::ptr GetFilePropertydirectoryTree(const UiFileProperty&uiFileProperty,const std::filesystem::path&selectedPath);
void LoadTone3000Auth();
void SetTone3000Auth(const std::string&apiKey);
std::string GetTone3000Auth() const;
};
+15 -1
View File
@@ -188,6 +188,10 @@ public:
{
return true;
}
else if (segment == "Tone3000Auth")
{
return true;
}
else if (segment == "PluginPresets")
{
return true;
@@ -734,7 +738,17 @@ public:
{
std::string segment = request_uri.segment(1);
if (segment == "uploadPluginPresets")
if (segment == "Tone3000Auth") {
// https://www.tone3000.com/api/v1/auth?redirect_url=http://10.0.0.151:8080/var/Tone3000Auth&otp_only=true
std::string apiKey = request_uri.query("api_key");
model->SetTone3000Auth(apiKey);
res.set(HttpField::content_type, "application/json");
res.set(HttpField::cache_control, "no-cache");
res.setBody("\"OK\"");
} else if (segment == "uploadPluginPresets")
{
PluginPresets presets;
fs::path filePath = req.get_body_temporary_file();