From ce9439e722d4d74e0eb77582d7df6932ce21c11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 13 May 2017 13:12:15 +0200 Subject: [PATCH] Display Lakka version in System Information --- frontend/drivers/platform_linux.c | 23 +++++++++++++++++++++++ frontend/drivers/platform_null.c | 3 +++ frontend/frontend_driver.h | 3 +++ intl/msg_hash_us.h | 2 ++ menu/menu_displaylist.c | 18 ++++++++++++++++++ msg_hash.h | 1 + 6 files changed, 50 insertions(+) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index de796161ad..8be904898f 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1205,6 +1205,26 @@ static void frontend_linux_get_os(char *s, #endif } +#ifdef HAVE_LAKKA +static void frontend_linux_get_lakka_version(char *s, + size_t len) +{ + char version[128]; + size_t vlen; + FILE *command_file = popen("cat /etc/release", "r"); + + fgets(version, sizeof(version), command_file); + vlen = strlen(version); + + if (vlen > 0 && version[vlen-1] == '\n') + version[--vlen] = '\0'; + + strlcpy(s, version, len); + + pclose(command_file); +} +#endif + static void frontend_linux_get_env(int *argc, char *argv[], void *data, void *params_data) { @@ -2131,6 +2151,9 @@ frontend_ctx_driver_t frontend_ctx_linux = { frontend_linux_destroy_signal_handler_state, NULL, /* attach_console */ NULL, /* detach_console */ +#ifdef HAVE_LAKKA + frontend_linux_get_lakka_version, /* get_lakka_version */ +#endif #ifdef ANDROID "android" #else diff --git a/frontend/drivers/platform_null.c b/frontend/drivers/platform_null.c index d43f782817..0f5e76d6ea 100644 --- a/frontend/drivers/platform_null.c +++ b/frontend/drivers/platform_null.c @@ -41,5 +41,8 @@ frontend_ctx_driver_t frontend_ctx_null = { NULL, /* destroy_sighandler_state */ NULL, /* attach_console */ NULL, /* detach_console */ +#ifdef HAVE_LAKKA + NULL, /* get_lakka_version */ +#endif "null", }; diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 14193468d4..a0e5b30ae4 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -85,6 +85,9 @@ typedef struct frontend_ctx_driver void (*destroy_signal_handler_state)(void); void (*attach_console)(void); void (*detach_console)(void); +#ifdef HAVE_LAKKA + void (*get_lakka_version)(char *, size_t); +#endif const char *ident; diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 4d47a5fe6a..1714a103b8 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1391,6 +1391,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_JACK_SUPPORT, "JACK support") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_KMS_SUPPORT, "KMS/EGL support") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION, + "Lakka Version") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBRETRODB_SUPPORT, "LibretroDB support") MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LIBUSB_SUPPORT, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index dda0f6a537..ba6a036162 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -679,6 +679,24 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); +#ifdef HAVE_LAKKA + if (frontend->get_lakka_version) + { + frontend->get_lakka_version(tmp2, sizeof(tmp2)); + + fill_pathname_noext(tmp, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION), + ": ", + sizeof(tmp)); + strlcat(tmp, frontend->get_lakka_version ? + tmp2 : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), + sizeof(tmp)); + menu_entries_append_enum(info->list, tmp, "", + MENU_ENUM_LABEL_SYSTEM_INFO_ENTRY, + MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + } +#endif + if (frontend->get_name) { frontend->get_name(tmp2, sizeof(tmp2)); diff --git a/msg_hash.h b/msg_hash.h index 905c6b7557..5426ebc237 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1382,6 +1382,7 @@ enum msg_hash_enums /* System information */ + MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_LAKKA_VERSION, MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_DYNAMIC_SUPPORT, MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_BUILD_DATE, MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION,