Skip to content

Commit

Permalink
Merge pull request #938 from g-maxime/MI_Version
Browse files Browse the repository at this point in the history
Windows GUI: New version dialog for plugins
  • Loading branch information
JeromeMartinez authored Nov 6, 2024
2 parents 27b1c4c + d9b2b6a commit 4e7a6ee
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 6 deletions.
44 changes: 44 additions & 0 deletions Source/GUI/VCL/GUI_Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,52 @@ void __fastcall TMainF::GUI_Configure()
if (!File::Exists(InstallFolder + __T("\\Plugin\\FFmpeg\\version.txt")))
MessageBox(NULL, __T("An error occured, please download and install the plugin manually from the MediaInfo download page."), __T("Error"), MB_OK);
}

Ztring FFmpegPluginVersion=Prefs->Config(__T("FFmpegPluginVersion"));
Ztring FFmpegPluginNewestVersion=Prefs->Config(__T("FFmpegPluginNewestVersion"));
if (!FFmpegPluginVersion.empty() && (FFmpegPluginNewestVersion.empty() || FFmpegPluginNewestVersion<FFmpegPluginVersion))
{
if (File::Exists(InstallFolder+__T("\\Plugin\\FFmpeg\\version.txt")))
{
int8u Buffer[65];
size_t Buffer_Size=File(InstallFolder+__T("\\Plugin\\FFmpeg\\version.txt")).Read(Buffer, 64);
Buffer[Buffer_Size]='\0';
Ztring VersionTxt=Ztring().From_UTF8((const char*)Buffer, Buffer_Size+1);
if (VersionTxt!=__T("") && VersionTxt<FFmpegPluginVersion)
{
TPluginF* P = new TPluginF(this, PLUGIN_FFMPEG);
if (P->Configure(true))
P->ShowModal();
delete P;
}
Prefs->Config(__T("FFmpegPluginNewestVersion"))=FFmpegPluginVersion;
Prefs->Config_Save();
}
}
#endif

Ztring GraphPluginVersion=Prefs->Config(__T("GraphPluginVersion"));
Ztring GraphPluginNewestVersion=Prefs->Config(__T("GraphPluginNewestVersion"));
if (!GraphPluginVersion.empty() && (GraphPluginNewestVersion.empty() || GraphPluginNewestVersion<GraphPluginVersion))
{
if (File::Exists(InstallFolder+__T("\\Plugin\\Graph\\version.txt")))
{
int8u Buffer[65];
size_t Buffer_Size=File(InstallFolder+__T("\\Plugin\\Graph\\version.txt")).Read(Buffer, 64);
Buffer[Buffer_Size]='\0';
Ztring VersionTxt=Ztring().From_UTF8((const char*)Buffer, Buffer_Size+1);
if (VersionTxt!=__T("") && VersionTxt<GraphPluginVersion)
{
TPluginF* P = new TPluginF(this, PLUGIN_GRAPH);
if (P->Configure(true))
P->ShowModal();
delete P;
}
Prefs->Config(__T("GraphPluginNewestVersion"))=GraphPluginVersion;
Prefs->Config_Save();
}
}

//Translation
Translate();

Expand Down
19 changes: 14 additions & 5 deletions Source/GUI/VCL/GUI_Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,17 @@ __fastcall TPluginF::TPluginF(TComponent* Owner, plugin Plugin)
}

//---------------------------------------------------------------------------
bool __fastcall TPluginF::Configure()
bool __fastcall TPluginF::Configure(bool Update)
{
// Get MediaInfo installation path
InstallFolder = Application->ExeName.c_str();
Ztring InstallFolder = Application->ExeName.c_str();
InstallFolder = InstallFolder.substr(0, InstallFolder.rfind(__T("\\")) + 1);

// Check requested plugin
if (Plugin >= PLUGIN_MAX)
{
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
if (!Update)
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
return false;
}

Expand All @@ -227,7 +228,8 @@ bool __fastcall TPluginF::Configure()
}
if (SourceURL.empty())
{
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
if (!Update)
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
return false;
}

Expand All @@ -236,13 +238,20 @@ bool __fastcall TPluginF::Configure()
TCHAR TempFileName[MAX_PATH + 1];
if (GetTempPath(MAX_PATH, TempPathBuffer) == 0 || GetTempFileName(TempPathBuffer, TEXT("MI_"), 0, TempFileName) == 0)
{
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
if (!Update)
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
return false;
}

TempPath = Ztring(TempFileName) + __T(".exe");
File::Move(Ztring(TempFileName), TempPath);

if (Update)
{
InfoLabel->Caption = __T("A new version of this plugin is available:");
AskLabel->Caption = __T("Would you like to update this plugin?");
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/GUI/VCL/GUI_Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class TPluginF : public TForm
public: // User declarations
__fastcall TPluginF(TComponent* Owner, plugin Plugin);

bool __fastcall Configure();
bool __fastcall Configure(bool Update=false);
void __fastcall DownloadInstaller();
void __fastcall RunInstaller();
void __fastcall Error();
Expand Down

0 comments on commit 4e7a6ee

Please sign in to comment.