@@ -3,17 +3,21 @@ Attribute VB_Name = "PluginManager"
33'3rd-Party Library Manager
44'Copyright 2014-2022 by Tanner Helland
55'Created: 30/August/15
6- 'Last updated: 28/February/22
7- 'Last update: add resvg
6+ 'Last updated: 13/October/22
7+ 'Last update: add a function for querying XP-compatibility; this will make it easier for the plugin manager UI
8+ ' to notify a user that non-functional plugins are simple XP-compatibility issues, not technical problems
89'
910'As with any project of reasonable size, PhotoDemon can't supply all of its needs through WAPI alone.
10- ' A number of third-party libraries are required for correct program operation.
11+ ' Current builds require a number of third-party libraries for full feature availability. (Some of these
12+ ' libraries are mandatory, some are not; PD will attempt to gracefully degrade feature availability if it
13+ ' can, but if you're acquiring PD from photodemon.org or it's official GitHub page you never need to
14+ ' worry about this.)
1115'
12- 'To simplify the management of these libraries, I've created this "plugin manager". Its purpose is
16+ 'To simplify the management of external libraries, I've created this small "plugin manager". It exists
1317' to make third-party library deployment and maintainence easier in a "portable" application context.
1418'
1519'When adding a new required library, please make sure to read the module-level declarations,
16- ' particularly the CORE_PLUGINS enum and the CORE_PLUGIN_COUNT constant at the top of this page .
20+ ' particularly the CORE_PLUGINS enum and the CORE_PLUGIN_COUNT constant at the top of this file .
1721'
1822'Unless otherwise noted, all source code in this file is shared under a simplified BSD license.
1923' Full license details are available in the LICENSE.md file, or at https://photodemon.org/license/
@@ -23,13 +27,13 @@ Attribute VB_Name = "PluginManager"
2327Option Explicit
2428
2529'This constant is used to iterate all core plugins (as listed under the CORE_PLUGINS enum),
26- ' so if you add or remove a plugin, YOU MUST update this . PD iterates plugins in order, so if
27- ' you do not update this, the plugin at the end of the chain (probably zstd) won't get
30+ ' so if you add or remove a plugin, YOU MUST UPDATE THIS . PhotoDemon iterates plugins in order,
31+ ' so if you do not update this count , the plugin at the end of the chain (probably zstd) won't be
2832' initialized and PD will crash.
2933Private Const CORE_PLUGIN_COUNT As Long = 14
3034
3135'Currently supported core plugins. These values are arbitrary and can be changed without consequence, but THEY MUST
32- ' ALWAYS BE SEQUENTIAL, STARTING WITH ZERO, because the enum is iterated using For loops (e.g. during initialization).
36+ ' ALWAYS BE SEQUENTIAL, STARTING WITH ZERO, because the enum is iterated using for..next loops (during initialization).
3337Public Enum CORE_PLUGINS
3438 CCP_CharLS
3539 CCP_ExifTool
@@ -468,40 +472,63 @@ Public Function IsPluginCurrentlyInstalled(ByVal pluginEnumID As CORE_PLUGINS) A
468472 IsPluginCurrentlyInstalled = Files.FileExists(PluginManager.GetPluginPath & GetPluginFilename(pluginEnumID))
469473End Function
470474
471- 'PD loads plugins in two waves. Before the splash screen appears, "high-priority" plugins are loaded. These include the
472- ' decompression plugins required to decompress things like the splash screen image. Much later in the load process,
473- ' we load the rest of the program's core plugins. This function determines which wave a plugin is loaded during.
475+ 'Some libraries are available on-demand (like libavif, which is enormous and most users won't need it).
476+ ' It's OK if these libraries are missing on a default install - it just means the user hasn't triggered
477+ ' any actions that prompt their download.
478+ Public Function IsPluginAvailableOnDemand (ByVal pluginID As CORE_PLUGINS ) As Boolean
479+
480+ IsPluginAvailableOnDemand = False
481+
482+ Select Case pluginID
483+ Case CCP_AvifExport, CCP_AvifImport
484+ IsPluginAvailableOnDemand = True
485+ End Select
486+
487+ End Function
488+
489+ 'PD loads plugins in two waves. Before the splash screen appears, "high-priority" plugins are loaded.
490+ ' These include compression plugins required to decompress things like the splash screen image.
491+ '
492+ 'Much later in the load process, we load other third-party libraries (if necessary - some may yet be loaded
493+ ' on-demand, as user operations require.
494+ '
495+ 'This function determines if a plugin is forcibly loaded during that initial "high-priority" wave, or later.
474496Public Function IsPluginHighPriority (ByVal pluginEnumID As CORE_PLUGINS ) As Boolean
497+
498+ IsPluginHighPriority = False
499+
475500 Select Case pluginEnumID
476- Case CCP_AvifExport
477- IsPluginHighPriority = False
478- Case CCP_AvifImport
479- IsPluginHighPriority = False
480- Case CCP_CharLS
481- IsPluginHighPriority = False
482- Case CCP_ExifTool
483- IsPluginHighPriority = False
484- Case CCP_EZTwain
485- IsPluginHighPriority = False
486- Case CCP_FreeImage
487- IsPluginHighPriority = False
488501 Case CCP_libdeflate
489502 IsPluginHighPriority = True
490- Case CCP_libjxl
491- IsPluginHighPriority = False
492503 Case CCP_LittleCMS
493504 IsPluginHighPriority = True
494505 Case CCP_lz4
495506 IsPluginHighPriority = True
496- Case CCP_pspiHost
497- IsPluginHighPriority = False
498- Case CCP_libwebp
499- IsPluginHighPriority = False
500- Case CCP_resvg
501- IsPluginHighPriority = False
502507 Case CCP_zstd
503508 IsPluginHighPriority = True
504509 End Select
510+
511+ End Function
512+
513+ 'As I've attempted to support more modern image formats (e.g. AVIF, HEIF, JPEG XL), I've also had to accept
514+ ' that it's just not feasible to build some of the required 3rd-party libraries in XP-compatible ways.
515+ ' This function can be used to query whether a plugin was disabled simply because it's not XP-compatible.
516+ ' (Ignore the return of this function when running on Vista+, obviously.)
517+ Public Function IsPluginUnavailableOnXP (ByVal pluginEnumID As CORE_PLUGINS ) As Boolean
518+
519+ IsPluginUnavailableOnXP = False
520+
521+ Select Case pluginEnumID
522+ Case CCP_AvifExport
523+ IsPluginUnavailableOnXP = True
524+ Case CCP_AvifImport
525+ IsPluginUnavailableOnXP = True
526+ Case CCP_libjxl
527+ IsPluginUnavailableOnXP = True
528+ Case CCP_resvg
529+ IsPluginUnavailableOnXP = True
530+ End Select
531+
505532End Function
506533
507534'Simplified function to return the expected version number of a plugin. These numbers change with each PD release, and they can
0 commit comments