Skip to content

Commit 4e7a6ee

Browse files
Merge pull request #938 from g-maxime/MI_Version
Windows GUI: New version dialog for plugins
2 parents 27b1c4c + d9b2b6a commit 4e7a6ee

File tree

3 files changed

+59
-6
lines changed

3 files changed

+59
-6
lines changed

Source/GUI/VCL/GUI_Main.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,52 @@ void __fastcall TMainF::GUI_Configure()
403403
if (!File::Exists(InstallFolder + __T("\\Plugin\\FFmpeg\\version.txt")))
404404
MessageBox(NULL, __T("An error occured, please download and install the plugin manually from the MediaInfo download page."), __T("Error"), MB_OK);
405405
}
406+
407+
Ztring FFmpegPluginVersion=Prefs->Config(__T("FFmpegPluginVersion"));
408+
Ztring FFmpegPluginNewestVersion=Prefs->Config(__T("FFmpegPluginNewestVersion"));
409+
if (!FFmpegPluginVersion.empty() && (FFmpegPluginNewestVersion.empty() || FFmpegPluginNewestVersion<FFmpegPluginVersion))
410+
{
411+
if (File::Exists(InstallFolder+__T("\\Plugin\\FFmpeg\\version.txt")))
412+
{
413+
int8u Buffer[65];
414+
size_t Buffer_Size=File(InstallFolder+__T("\\Plugin\\FFmpeg\\version.txt")).Read(Buffer, 64);
415+
Buffer[Buffer_Size]='\0';
416+
Ztring VersionTxt=Ztring().From_UTF8((const char*)Buffer, Buffer_Size+1);
417+
if (VersionTxt!=__T("") && VersionTxt<FFmpegPluginVersion)
418+
{
419+
TPluginF* P = new TPluginF(this, PLUGIN_FFMPEG);
420+
if (P->Configure(true))
421+
P->ShowModal();
422+
delete P;
423+
}
424+
Prefs->Config(__T("FFmpegPluginNewestVersion"))=FFmpegPluginVersion;
425+
Prefs->Config_Save();
426+
}
427+
}
406428
#endif
407429

430+
Ztring GraphPluginVersion=Prefs->Config(__T("GraphPluginVersion"));
431+
Ztring GraphPluginNewestVersion=Prefs->Config(__T("GraphPluginNewestVersion"));
432+
if (!GraphPluginVersion.empty() && (GraphPluginNewestVersion.empty() || GraphPluginNewestVersion<GraphPluginVersion))
433+
{
434+
if (File::Exists(InstallFolder+__T("\\Plugin\\Graph\\version.txt")))
435+
{
436+
int8u Buffer[65];
437+
size_t Buffer_Size=File(InstallFolder+__T("\\Plugin\\Graph\\version.txt")).Read(Buffer, 64);
438+
Buffer[Buffer_Size]='\0';
439+
Ztring VersionTxt=Ztring().From_UTF8((const char*)Buffer, Buffer_Size+1);
440+
if (VersionTxt!=__T("") && VersionTxt<GraphPluginVersion)
441+
{
442+
TPluginF* P = new TPluginF(this, PLUGIN_GRAPH);
443+
if (P->Configure(true))
444+
P->ShowModal();
445+
delete P;
446+
}
447+
Prefs->Config(__T("GraphPluginNewestVersion"))=GraphPluginVersion;
448+
Prefs->Config_Save();
449+
}
450+
}
451+
408452
//Translation
409453
Translate();
410454

Source/GUI/VCL/GUI_Plugin.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,17 @@ __fastcall TPluginF::TPluginF(TComponent* Owner, plugin Plugin)
197197
}
198198

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

206206
// Check requested plugin
207207
if (Plugin >= PLUGIN_MAX)
208208
{
209-
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
209+
if (!Update)
210+
MessageBox(NULL, __T("Unable to find installer for the requested plugin, please download it manually from the MediaInfo download page."), __T("Error"), MB_OK);
210211
return false;
211212
}
212213

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

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

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

249+
if (Update)
250+
{
251+
InfoLabel->Caption = __T("A new version of this plugin is available:");
252+
AskLabel->Caption = __T("Would you like to update this plugin?");
253+
}
254+
246255
return true;
247256
}
248257

Source/GUI/VCL/GUI_Plugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class TPluginF : public TForm
100100
public: // User declarations
101101
__fastcall TPluginF(TComponent* Owner, plugin Plugin);
102102

103-
bool __fastcall Configure();
103+
bool __fastcall Configure(bool Update=false);
104104
void __fastcall DownloadInstaller();
105105
void __fastcall RunInstaller();
106106
void __fastcall Error();

0 commit comments

Comments
 (0)