Skip to content

Commit

Permalink
Create CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Feb 7, 2016
1 parent 452df47 commit b647e81
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 39 deletions.
18 changes: 15 additions & 3 deletions core_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ core_info_t *core_info_get(core_info_list_t *list, size_t i)
}


void core_info_list_update_missing_firmware(
static bool core_info_list_update_missing_firmware(
core_info_list_t *core_info_list,
const char *core, const char *systemdir)
{
Expand All @@ -586,10 +586,10 @@ void core_info_list_update_missing_firmware(
core_info_t *info = NULL;

if (!core_info_list || !core)
return;
return false;

if (!(info = core_info_find(core_info_list, core)))
return;
return false;

for (i = 0; i < info->firmware_count; i++)
{
Expand All @@ -600,6 +600,8 @@ void core_info_list_update_missing_firmware(
info->firmware[i].path, sizeof(path));
info->firmware[i].missing = !path_file_exists(path);
}

return true;
}

#if 0
Expand Down Expand Up @@ -690,6 +692,16 @@ bool core_info_ctl(enum core_info_state state, void *data)
*core = core_info_curr_list;
}
break;
case CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE:
{
core_info_ctx_firmware_t *info = (core_info_ctx_firmware_t*)data;
if (!info)
return false;

return core_info_list_update_missing_firmware(core_info_curr_list,
info->path, info->system_directory);
}
break;
case CORE_INFO_CTL_FIND:
{
core_info_ctx_find_t *info = (core_info_ctx_find_t*)data;
Expand Down
10 changes: 7 additions & 3 deletions core_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum core_info_state
CORE_INFO_CTL_LIST_DEINIT,
CORE_INFO_CTL_LIST_INIT,
CORE_INFO_CTL_LIST_GET,
CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE,
CORE_INFO_CTL_CURRENT_CORE_FREE,
CORE_INFO_CTL_CURRENT_CORE_INIT,
CORE_INFO_CTL_CURRENT_CORE_GET,
Expand Down Expand Up @@ -82,6 +83,12 @@ typedef struct
char *all_ext;
} core_info_list_t;

typedef struct core_info_ctx_firmware
{
const char *path;
const char *system_directory;
} core_info_ctx_firmware_t;

typedef struct core_info_ctx_find
{
core_info_t *inf;
Expand All @@ -92,9 +99,6 @@ typedef struct core_info_ctx_find
void core_info_list_get_supported_cores(core_info_list_t *list,
const char *path, const core_info_t **infos, size_t *num_infos);

void core_info_list_update_missing_firmware(core_info_list_t *list,
const char *core, const char *systemdir);

/* Shallow-copies internal state. Data in *info is invalidated when the
* core_info_list is freed. */
bool core_info_list_get_info(core_info_list_t *list,
Expand Down
67 changes: 34 additions & 33 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,44 +269,45 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info)

if (core_info->firmware_count > 0)
{
core_info_list_t *list = NULL;
core_info_ctx_firmware_t firmware_info;

core_info_ctl(CORE_INFO_CTL_LIST_GET, &list);
firmware_info.path = core_info->path;
firmware_info.system_directory = settings->system_directory;

core_info_list_update_missing_firmware(list, core_info->path,
settings->system_directory);

strlcpy(tmp, menu_hash_to_str(MENU_LABEL_VALUE_CORE_INFO_FIRMWARE),
sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
menu_entries_push(info->list, tmp, "",
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
if (core_info_ctl(CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE, &firmware_info))
{
strlcpy(tmp, menu_hash_to_str(MENU_LABEL_VALUE_CORE_INFO_FIRMWARE),
sizeof(tmp));
strlcat(tmp, ": ", sizeof(tmp));
menu_entries_push(info->list, tmp, "",
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);

/* FIXME: This looks hacky and probably
* needs to be improved for good translation support. */
/* FIXME: This looks hacky and probably
* needs to be improved for good translation support. */

for (i = 0; i < core_info->firmware_count; i++)
{
if (core_info->firmware[i].desc)
for (i = 0; i < core_info->firmware_count; i++)
{
snprintf(tmp, sizeof(tmp), " %s: %s",
menu_hash_to_str(MENU_LABEL_VALUE_RDB_ENTRY_NAME),
core_info->firmware[i].desc ?
core_info->firmware[i].desc : "");
menu_entries_push(info->list, tmp, "",
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);

snprintf(tmp, sizeof(tmp), " %s: %s, %s",
menu_hash_to_str(MENU_VALUE_STATUS),
core_info->firmware[i].missing ?
menu_hash_to_str(MENU_VALUE_MISSING) :
menu_hash_to_str(MENU_VALUE_PRESENT),
core_info->firmware[i].optional ?
menu_hash_to_str(MENU_VALUE_OPTIONAL) :
menu_hash_to_str(MENU_VALUE_REQUIRED)
);
menu_entries_push(info->list, tmp, "",
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
if (core_info->firmware[i].desc)
{
snprintf(tmp, sizeof(tmp), " %s: %s",
menu_hash_to_str(MENU_LABEL_VALUE_RDB_ENTRY_NAME),
core_info->firmware[i].desc ?
core_info->firmware[i].desc : "");
menu_entries_push(info->list, tmp, "",
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);

snprintf(tmp, sizeof(tmp), " %s: %s, %s",
menu_hash_to_str(MENU_VALUE_STATUS),
core_info->firmware[i].missing ?
menu_hash_to_str(MENU_VALUE_MISSING) :
menu_hash_to_str(MENU_VALUE_PRESENT),
core_info->firmware[i].optional ?
menu_hash_to_str(MENU_VALUE_OPTIONAL) :
menu_hash_to_str(MENU_VALUE_REQUIRED)
);
menu_entries_push(info->list, tmp, "",
MENU_SETTINGS_CORE_INFO_NONE, 0, 0);
}
}
}
}
Expand Down

0 comments on commit b647e81

Please sign in to comment.