From f014bf4b7df43a15e1ea676f3993ab0452a8d00c Mon Sep 17 00:00:00 2001 From: jthedering <51533355+jthedering@users.noreply.github.com> Date: Sun, 17 Jul 2016 13:08:59 +0000 Subject: [PATCH] Fixed: When a file was selected for the Include command in the Configuration Editor that was not readable by the audio service, no warning appeared. Fixed: When the Include command was used to load the configuration file itself or another file including the file, Equalizer APO could crash. The recursion depth is now limited to 100. --- Editor/guis/IncludeFilterGUI.cpp | 47 ++++++++ Editor/guis/IncludeFilterGUI.h | 2 + Editor/guis/IncludeFilterGUI.ui | 90 +++++++++++---- Editor/translations/Editor_de.qm | Bin 22385 -> 23019 bytes Editor/translations/Editor_de.ts | 183 +++++++++++++++++-------------- filters/IncludeFilterFactory.cpp | 30 ++++- filters/IncludeFilterFactory.h | 5 + 7 files changed, 249 insertions(+), 108 deletions(-) diff --git a/Editor/guis/IncludeFilterGUI.cpp b/Editor/guis/IncludeFilterGUI.cpp index 16fa320..e060ca2 100644 --- a/Editor/guis/IncludeFilterGUI.cpp +++ b/Editor/guis/IncludeFilterGUI.cpp @@ -19,6 +19,7 @@ #include +#include "helpers/RegistryHelper.h" #include "IncludeFilterGUI.h" #include "ui_IncludeFilterGUI.h" @@ -28,6 +29,8 @@ IncludeFilterGUI::IncludeFilterGUI(FilterTable* filterTable, const QString& path ui->setupUi(this); ui->pathLineEdit->setText(path); + + updateFileInfo(); } IncludeFilterGUI::~IncludeFilterGUI() @@ -61,6 +64,7 @@ void IncludeFilterGUI::on_selectFileToolButton_clicked() if (relativePath.startsWith("../../")) relativePath = absolutePath; ui->pathLineEdit->setText(QDir::toNativeSeparators(relativePath)); + updateFileInfo(); emit updateModel(); } @@ -68,6 +72,8 @@ void IncludeFilterGUI::on_selectFileToolButton_clicked() void IncludeFilterGUI::on_pathLineEdit_editingFinished() { + updateFileInfo(); + emit updateModel(); } @@ -83,3 +89,44 @@ void IncludeFilterGUI::on_openFileToolButton_clicked() filterTable->openConfig(fileInfo.absoluteFilePath()); } } + +void IncludeFilterGUI::updateFileInfo() +{ + QString error = ""; + + QString path = ui->pathLineEdit->text(); + if (path.length() == 0) + { + error = tr("No file selected"); + } + else + { + QFileInfo fileInfo(filterTable->getConfigPath()); + QDir configDir = fileInfo.absoluteDir(); + fileInfo.setFile(configDir, path); + if (!fileInfo.exists()) + { + error = tr("File not found"); + } + else + { + path = QDir::toNativeSeparators(fileInfo.absoluteFilePath()); + + ACCESS_MASK mask = GENERIC_READ; + try + { + mask = RegistryHelper::getFileAccessForUser(path.toStdWString(), SECURITY_LOCAL_SERVICE_RID); + } + catch (RegistryException e) + { + // ignore + } + + if ((mask & GENERIC_READ) != GENERIC_READ && (mask & FILE_GENERIC_READ) != FILE_GENERIC_READ) + error = tr("The file is not readable for the audio service.\nChange the file permissions or copy the file to the config directory."); + } + } + + ui->errorLabel->setVisible(error.length() > 0); + ui->errorLabel->setText(error); +} diff --git a/Editor/guis/IncludeFilterGUI.h b/Editor/guis/IncludeFilterGUI.h index ce0aaac..0f68b7d 100644 --- a/Editor/guis/IncludeFilterGUI.h +++ b/Editor/guis/IncludeFilterGUI.h @@ -42,6 +42,8 @@ private slots: void on_openFileToolButton_clicked(); private: + void updateFileInfo(); + Ui::IncludeFilterGUI* ui; FilterTable* filterTable; }; diff --git a/Editor/guis/IncludeFilterGUI.ui b/Editor/guis/IncludeFilterGUI.ui index 5d59404..03fd332 100644 --- a/Editor/guis/IncludeFilterGUI.ui +++ b/Editor/guis/IncludeFilterGUI.ui @@ -13,7 +13,7 @@ - + 0 @@ -26,28 +26,7 @@ 0 - - - - Include: - - - - - - - - - - Select file - - - - :/icons/document-open.ico:/icons/document-open.ico - - - - + Qt::Horizontal @@ -71,6 +50,71 @@ + + + + + + + Select file + + + + :/icons/document-open.ico:/icons/document-open.ico + + + + + + + Include: + + + + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + + + diff --git a/Editor/translations/Editor_de.qm b/Editor/translations/Editor_de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x%hKr`VK{ z6|z%=FE~V-4K&IhC=oi9qNO)BCQ`ZPtk$wHSLsxoL@uaL-Sf|D-|hQ-e}25*&mV)_ zqkisSxM2Yh`xO6wrY1r%@E?ns+mek{*%d(9D3D(Z;lrJP?Gl8`0$>k7m>}lehVWG! z;0%Lsa}HR}L3EV>@ed$w`W$c>Aa(@-@5>O+S%Iiq5WlDfVn!iOkZ#e7ZD)*o%t0i? z=KijU|V(;i~n3cPwYj_O=S&0Qxp!gLaE^gRX&|HPKMd?0BR zX6~H@GWT)ZbQ=)OIL#9~kh_{&vHKMue3)C`dlD#~n8@ zfwb@W$qssyaZJ!|KMpJn7YcoJR{X--n>$Eb#r!H`fzK=SjYv$ksQe~ z68|BV2&YURs&c4HVR~PCjOj&)yGc0@B7ie*vrNr9Sr#+EI%%dhP`> zp+>rv+e6`sm40xh0Qzmx?TTtL!7lT4m*{@HEKPq(^Svn>j?e%p*JR`GS14k;<)nZU zSopqd>!EPE-Ln7Ib&6D*yz4E}P5wk~c9v6}V1hjI$Vkncm&a$G(!%b^55L|EJkujj z55-c-yVO}7v;j{h^9x3Yb58Bwd>EK-Rkt>hSIJw|T_vT|$Bg>w;@>D~$24*~d2XrE zr2b9MV$GWM@fQK@cbbNQU#R|%Y+NvfIc{j)8x8``o(QpcArnQ{bN0nb<_DzaNLB25 zigK7c#59lMefTj@GQ|9%DKYJkQhhO!j&;i3o4uq`sWjWY6rfgRI8aY+bSPKnaw#Mh z_L*pOr0>vLv&bZClhzfn3|O{CyD5S4SGY~PrC|ifG3%u6dxT)*iRV)gW0xzVerstärkung: - + Peaking filter Peaking-Filter - + Low-pass filter Tiefpassfilter - + High-pass filter Hochpassfilter - + Band-pass filter Bandpassfilter - + Low-shelf filter Low Shelf-Filter - + High-shelf filter High Shelf-Filter - + Notch filter Notchfilter - + All-pass filter Allpassfilter - + Center frequency Mittenfrequenz - + Corner frequency Eckfrequenz - + Fixed Q Festes Q - - + + Fixed S Festes S - + Q factor Q-Faktor - + Bandwidth Bandbreite - - + + Slope Steilheit @@ -469,7 +469,7 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.DelayFilterGUI - + ms ms @@ -489,7 +489,7 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.Samples - + samples Samples @@ -592,37 +592,37 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.Nur Geräte mit installiertem APO zeigen - + Connection Anschluss - + Device Gerät - + State Status - + Playback devices Wiedergabegeräte - + Capture devices Aufnahmegeräte - + APO installed APO installiert - + APO not installed APO nicht installiert @@ -647,7 +647,7 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts. FilterTable - + Add filter Filter hinzufügen @@ -745,17 +745,17 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.variabel - + Import Importieren - + Export Exportieren - + Invert response Frequenzgang invertieren @@ -764,34 +764,34 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.Frequenzgang spiegeln - + Normalize response Frequenzgang normalisieren - + Reset response Frequenzgang zurücksetzen - + Import frequency response Frequenzgang importieren - - + + Frequency response (*.csv) Frequenzgang (*.csv) - - + + All files (*.*) Alle Dateien (*.*) - + Export frequency response Frequenzgang exportieren @@ -824,30 +824,47 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts. IncludeFilterGUI - + Include: Einbinden: - + Select file Datei auswählen - + Open file in editor Datei im Editor öffnen - + Include file Datei einbinden - + E-APO configurations (*.txt) E-APO-Konfigurationen (*.txt) + + + No file selected + Keine Datei gewählt + + + + File not found + Datei nicht gefunden + + + + The file is not readable for the audio service. +Change the file permissions or copy the file to the config directory. + Die Datei ist für den Audiodienst nicht lesbar. +Ändern Sie die Dateiberechtigungen oder kopieren Sie die Datei in das config-Verzeichnis. + IncludeFilterGUIFactory @@ -1053,32 +1070,32 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.Alle dateispezifischen Einstellungen zurücksetzen - + Equalizer APO %0 Configuration Editor Equalizer APO %0 Konfigurationseditor - + Instant mode Sofort-Modus - + Changes are saved immediately Änderungen werden sofort gespeichert - + Device: Gerät: - + Channel configuration: Kanalkonfiguration: - + Default Standard @@ -1091,17 +1108,17 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.Eingabegeräte: - + Playback devices: Wiedergabegeräte: - + Capture devices: Aufnahmegeräte: - + Registry problem Registry-Problem @@ -1110,31 +1127,31 @@ Wählen Sie eine andere Datei oder ändern Sie die Konfiguration des Geräts.Ein Registrywert, der für den Betrieb von Equalizer APO erforderlich ist, ist nicht korrekt gesetzt. Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben? - + A registry value that is required for the operation of Equalizer APO is not set correctly. Do you want to run the Configurator application to fix the problem? Ein Registrywert, der für den Betrieb von Equalizer APO erforderlich ist, ist nicht korrekt gesetzt. Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben? - + APO not installed to device APO nicht für das Gerät installiert - + Equalizer APO has not been installed to the selected device. Do you want to run the Configurator application to fix the problem? Equalizer APO wurde nicht für das gewählte Gerät installiert. Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben? - + Audio enhancements disabled Signalverbesserungen deaktiviert - + Audio enhancements are not enabled for the device %0 %1. Do you want to run the Configurator application to fix the problem? @@ -1143,35 +1160,35 @@ Do you want to run the Configurator application to fix the problem? Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben? - - - + + + Error Fehler - + Error while reading configuration file: %0 Fehler beim Lesen der Konfigurationsdatei: %0 - + Error while writing configuration file: %0 Fehler beim Schreiben der Konfigurationsdatei: %0 - + Only %0/%1 bytes have been written! Nur %0/%1 Bytes wurden geschrieben! - + From device Von Gerät - + %0 dB %0 dB @@ -1180,7 +1197,7 @@ Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben?%0 ms (%1 Samp.) - + %0 ms (%1 s.) %0 ms (%1 S.) @@ -1189,67 +1206,67 @@ Möchten Sie die Configurator-Anwendung starten, um das Problem zu beheben?%0 ms (%1 Samples) - + %0 ms %0 ms - + %0 % (one core) %0 % (ein Kern) - - - + + + Restart required Neustart erforderlich - - - + + + Configuration Editor will be restarted to apply the changed settings. Proceed? Konfigurationseditor wird neugestartet, um die geänderten Einstellungen zu übernehmen. Fortsetzen? - + Unsaved changes Ungespeicherte Änderungen - + The configuration file %0 has unsaved changes. Die Konfigurationsdatei %0 hat ungespeicherte Änderungen. - + Do you want to save the changes before closing the file? Möchten Sie die Änderungen speichern, bevor die Datei geschlossen wird? - + Open file Datei öffnen - + Automatic (%0) Automatisch (%0) - - + + E-APO configurations (*.txt) E-APO-Konfigurationen (*.txt) - + Save file as Datei speichern unter - + Unsaved Ungespeichert diff --git a/filters/IncludeFilterFactory.cpp b/filters/IncludeFilterFactory.cpp index 4bfb8d3..78226a8 100644 --- a/filters/IncludeFilterFactory.cpp +++ b/filters/IncludeFilterFactory.cpp @@ -27,11 +27,27 @@ using namespace std; +const int RECURSION_LIMIT = 100; + void IncludeFilterFactory::initialize(FilterEngine* engine) { this->engine = engine; } +vector IncludeFilterFactory::startOfConfiguration() +{ + recursionDepth = -1; + + return vector(); +} + +vector IncludeFilterFactory::startOfFile(const wstring& configPath) +{ + recursionDepth++; + + return vector(); +} + vector IncludeFilterFactory::createFilter(const wstring& configPath, wstring& command, wstring& parameters) { if (command == L"Include") @@ -56,9 +72,19 @@ vector IncludeFilterFactory::createFilter(const wstring& configPath, w else includePath = value; - engine->loadConfigFile(includePath); + if (recursionDepth >= RECURSION_LIMIT) + LogF(L"Skipping include of %s as recursion limit of %d has been reached", value.c_str(), RECURSION_LIMIT); + else + engine->loadConfigFile(includePath); command = L""; } return vector(); -} \ No newline at end of file +} + +std::vector IncludeFilterFactory::endOfFile(const wstring& configPath) +{ + recursionDepth--; + + return vector(); +} diff --git a/filters/IncludeFilterFactory.h b/filters/IncludeFilterFactory.h index 4900770..c7e75cd 100644 --- a/filters/IncludeFilterFactory.h +++ b/filters/IncludeFilterFactory.h @@ -28,8 +28,13 @@ class IncludeFilterFactory : public IFilterFactory { public: void initialize(FilterEngine* engine) override; + + std::vector startOfConfiguration() override; + std::vector startOfFile(const std::wstring& configPath) override; std::vector createFilter(const std::wstring& configPath, std::wstring& command, std::wstring& parameters) override; + std::vector endOfFile(const std::wstring& configPath) override; private: FilterEngine* engine; + int recursionDepth = -1; };