Skip to content

Commit

Permalink
ModuleManager and PluginManager don't use AudacityMessageBox
Browse files Browse the repository at this point in the history
(cherry picked from commit b01bc73;
modified for Tenacity)
Signed-off-by: Avery King <[email protected]>
  • Loading branch information
Paul-Licameli authored and generic-pers0n committed Aug 27, 2024
1 parent 05eb203 commit 6c36e5d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
40 changes: 22 additions & 18 deletions src/ModuleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ i.e. an alternative to the usual interface, for Audacity.
#include "ModuleSettings.h"
#endif

#include "widgets/AudacityMessageBox.h"

#define initFnName "ExtensionModuleInit"
#define versionFnName "GetVersionString"

Expand All @@ -60,11 +58,19 @@ Module::~Module()
{
}

static GenericUI::MessageBoxResult DoMessageBox(const TranslatableString &msg)
{
using namespace GenericUI;
return ShowMessageBox(msg,
MessageBoxOptions{}.Caption(XO("Module Unsuitable")));
}

void Module::ShowLoadFailureError(const wxString &Error)
{
auto ShortName = wxFileName(mName).GetName();
AudacityMessageBox(XO("Unable to load the \"%s\" module.\n\nError: %s").Format(ShortName, Error),
XO("Module Unsuitable"));
DoMessageBox(
XO("Unable to load the \"%s\" module.\n\nError: %s")
.Format(ShortName, Error));
wxLogMessage(wxT("Unable to load the module \"%s\". Error: %s"), mName, Error);
}

Expand Down Expand Up @@ -94,22 +100,20 @@ bool Module::Load(wxString &deferredErrorMessage)
// Check version string matches. (For now, they must match exactly)
tVersionFn versionFn = (tVersionFn)(mLib->GetSymbol(wxT(versionFnName)));
if (versionFn == NULL){
AudacityMessageBox(
DoMessageBox(
XO("The module \"%s\" does not provide a version string.\n\nIt will not be loaded.")
.Format( ShortName),
XO("Module Unsuitable"));
.Format( ShortName));
wxLogMessage(wxT("The module \"%s\" does not provide a version string. It will not be loaded."), mName);
mLib->Unload();
return false;
}

wxString moduleVersion = versionFn();
if( moduleVersion != TENACITY_VERSION_STRING) {
AudacityMessageBox(
XO("The module \"%s\" is matched with Tenacity version \"%s\".\n\nIt will not be loaded.")
.Format(ShortName, moduleVersion),
XO("Module Unsuitable"));
wxLogMessage(wxT("The module \"%s\" is matched with Tenacity version \"%s\". It will not be loaded."), mName, moduleVersion);
DoMessageBox(
XO("The module \"%s\" is matched with Audacity version \"%s\".\n\nIt will not be loaded.")
.Format(ShortName, moduleVersion));
wxLogMessage(wxT("The module \"%s\" is matched with Audacity version \"%s\". It will not be loaded."), mName, moduleVersion);
mLib->Unload();
return false;
}
Expand All @@ -129,9 +133,9 @@ bool Module::Load(wxString &deferredErrorMessage)

mDispatch = NULL;

AudacityMessageBox(
XO("The module \"%s\" failed to initialize.\n\nIt will not be loaded.").Format(ShortName),
XO("Module Unsuitable"));
DoMessageBox(
XO("The module \"%s\" failed to initialize.\n\nIt will not be loaded.")
.Format(ShortName));
wxLogMessage(wxT("The module \"%s\" failed to initialize.\nIt will not be loaded."), mName);
mLib->Unload();

Expand Down Expand Up @@ -324,9 +328,9 @@ void ModuleManager::TryLoadModules(
if (!module->HasDispatch())
{
auto ShortName = wxFileName(file).GetName();
AudacityMessageBox(
XO("The module \"%s\" does not provide any of the required functions.\n\nIt will not be loaded.").Format(ShortName),
XO("Module Unsuitable"));
DoMessageBox(
XO("The module \"%s\" does not provide any of the required functions.\n\nIt will not be loaded.")
.Format(ShortName));
wxLogMessage(wxT("The module \"%s\" does not provide any of the required functions. It will not be loaded."), file);
module->Unload();
}
Expand Down
21 changes: 12 additions & 9 deletions src/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ for shared and private configs - which need to move out.
#include <wx/log.h>
#include <wx/tokenzr.h>

#include "BasicUI.h"
#include "ModuleInterface.h"

// Tenacity libraries
Expand All @@ -36,7 +37,6 @@ for shared and private configs - which need to move out.

#include "ModuleManager.h"
#include "PlatformCompatibility.h"
#include "widgets/AudacityMessageBox.h"

///////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -644,6 +644,7 @@ void PluginManager::Terminate()

bool PluginManager::DropFile(const wxString &fileName)
{
using namespace GenericUI;
auto &mm = ModuleManager::Get();
const wxFileName src{ fileName };

Expand Down Expand Up @@ -673,11 +674,12 @@ bool PluginManager::DropFile(const wxString &fileName)
dst.SetFullName( src.GetFullName() );
if ( dst.Exists() ) {
// Query whether to overwrite
bool overwrite = (wxYES == ::AudacityMessageBox(
bool overwrite = (MessageBoxResult::Yes == ShowMessageBox(
XO("Overwrite the plug-in file %s?")
.Format( dst.GetFullPath() ),
XO("Plug-in already exists"),
wxYES_NO ) );
MessageBoxOptions{}
.Caption(XO("Plug-in already exists"))
.ButtonStyle(Button::YesNo)));
if ( !overwrite )
return true;
}
Expand All @@ -697,7 +699,7 @@ bool PluginManager::DropFile(const wxString &fileName)
}

if (!copied) {
::AudacityMessageBox(
ShowMessageBox(
XO("Plug-in file is in use. Failed to overwrite") );
return true;
}
Expand All @@ -718,7 +720,7 @@ bool PluginManager::DropFile(const wxString &fileName)
});
if ( ! nPlugIns ) {
// Unlikely after the dry run succeeded
::AudacityMessageBox(
ShowMessageBox(
XO("Failed to register:\n%s").Format( errMsg ) );
return true;
}
Expand All @@ -735,10 +737,11 @@ bool PluginManager::DropFile(const wxString &fileName)
)( nIds );
for (const auto &name : names)
message.Join( Verbatim( name ), wxT("\n") );
bool enable = (wxYES == ::AudacityMessageBox(
bool enable = (MessageBoxResult::Yes == ShowMessageBox(
message,
XO("Enable new plug-ins"),
wxYES_NO ) );
MessageBoxOptions{}
.Caption(XO("Enable new plug-ins"))
.ButtonStyle(Button::YesNo)));
for (const auto &id : ids)
mPlugins[id].SetEnabled(enable);
// Make changes to enabled status persist:
Expand Down

0 comments on commit 6c36e5d

Please sign in to comment.