Improvement for multi-mode option.

Now you can use for example theme_uefi and theme at the same time.
This commit is contained in:
longpanda 2021-10-27 20:08:47 +08:00
parent eb8fcc8f30
commit 09162e8d97
2 changed files with 31 additions and 20 deletions

View file

@ -550,6 +550,7 @@ typedef struct plugin_entry
const char *key; const char *key;
ventoy_plugin_entry_pf entryfunc; ventoy_plugin_entry_pf entryfunc;
ventoy_plugin_check_pf checkfunc; ventoy_plugin_check_pf checkfunc;
int flag;
}plugin_entry; }plugin_entry;
typedef struct replace_fs_dir typedef struct replace_fs_dir

View file

@ -2338,45 +2338,55 @@ static int ventoy_plugin_image_list_check(VTOY_JSON *json, const char *isodisk)
static plugin_entry g_plugin_entries[] = static plugin_entry g_plugin_entries[] =
{ {
{ "control", ventoy_plugin_control_entry, ventoy_plugin_control_check }, { "control", ventoy_plugin_control_entry, ventoy_plugin_control_check, 0 },
{ "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check }, { "theme", ventoy_plugin_theme_entry, ventoy_plugin_theme_check, 0 },
{ "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check }, { "auto_install", ventoy_plugin_auto_install_entry, ventoy_plugin_auto_install_check, 0 },
{ "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check }, { "persistence", ventoy_plugin_persistence_entry, ventoy_plugin_persistence_check, 0 },
{ "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check }, { "menu_alias", ventoy_plugin_menualias_entry, ventoy_plugin_menualias_check, 0 },
{ "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check }, { "menu_tip", ventoy_plugin_menutip_entry, ventoy_plugin_menutip_check, 0 },
{ "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check }, { "menu_class", ventoy_plugin_menuclass_entry, ventoy_plugin_menuclass_check, 0 },
{ "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check }, { "injection", ventoy_plugin_injection_entry, ventoy_plugin_injection_check, 0 },
{ "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check }, { "auto_memdisk", ventoy_plugin_auto_memdisk_entry, ventoy_plugin_auto_memdisk_check, 0 },
{ "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check }, { "image_list", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
{ "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check }, { "image_blacklist", ventoy_plugin_image_list_entry, ventoy_plugin_image_list_check, 0 },
{ "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check }, { "conf_replace", ventoy_plugin_conf_replace_entry, ventoy_plugin_conf_replace_check, 0 },
{ "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check }, { "dud", ventoy_plugin_dud_entry, ventoy_plugin_dud_check, 0 },
{ "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check }, { "password", ventoy_plugin_pwd_entry, ventoy_plugin_pwd_check, 0 },
{ "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check }, { "custom_boot", ventoy_plugin_custom_boot_entry, ventoy_plugin_custom_boot_check, 0 },
}; };
static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk) static int ventoy_parse_plugin_config(VTOY_JSON *json, const char *isodisk)
{ {
int i; int i;
char key[128]; char key[128];
VTOY_JSON *cur = json; VTOY_JSON *cur = NULL;
grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk); grub_snprintf(g_iso_disk_name, sizeof(g_iso_disk_name), "%s", isodisk);
while (cur) for (cur = json; cur; cur = cur->pstNext)
{ {
for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++) for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
{ {
grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, g_arch_mode_suffix); grub_snprintf(key, sizeof(key), "%s_%s", g_plugin_entries[i].key, g_arch_mode_suffix);
if (grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0 || grub_strcmp(key, cur->pcName) == 0) if (g_plugin_entries[i].flag == 0 && grub_strcmp(key, cur->pcName) == 0)
{ {
debug("Plugin entry for %s\n", g_plugin_entries[i].key); debug("Plugin entry for %s\n", g_plugin_entries[i].key);
g_plugin_entries[i].entryfunc(cur, isodisk); g_plugin_entries[i].entryfunc(cur, isodisk);
g_plugin_entries[i].flag = 1;
break; break;
} }
} }
cur = cur->pstNext; for (i = 0; i < (int)ARRAY_SIZE(g_plugin_entries); i++)
{
if (g_plugin_entries[i].flag == 0 && grub_strcmp(g_plugin_entries[i].key, cur->pcName) == 0)
{
debug("Plugin entry for %s\n", g_plugin_entries[i].key);
g_plugin_entries[i].entryfunc(cur, isodisk);
g_plugin_entries[i].flag = 1;
break;
}
}
} }
return 0; return 0;