Implement core_updater_list more conventionally so that iOS menu

(hopefully) will start rendering it correctly
This commit is contained in:
twinaphex 2015-02-27 09:25:09 +01:00
parent e7fe92748b
commit fedf5f1a6b
2 changed files with 64 additions and 56 deletions

View File

@ -1539,14 +1539,15 @@ static void print_buf_lines(file_list_t *list, char *buf, int buf_size,
/* HACK - we have to find some way to pass state inbetween /* HACK - we have to find some way to pass state inbetween
* function pointer callback functions that don't necessarily * function pointer callback functions that don't necessarily
* call each other. */ * call each other. */
static char core_updater_list_path[PATH_MAX_LENGTH]; extern char core_updater_list_path[PATH_MAX_LENGTH];
static char core_updater_list_label[PATH_MAX_LENGTH]; extern char core_updater_list_label[PATH_MAX_LENGTH];
static unsigned core_updater_list_type; extern unsigned core_updater_list_type;
static char *core_buf;
static size_t core_len;
int cb_core_updater_list(void *data_, size_t len) int cb_core_updater_list(void *data_, size_t len)
{ {
char *data = (char*)data_; char *data = (char*)data_;
file_list_t *list = NULL;
menu_handle_t *menu = menu_driver_resolve(); menu_handle_t *menu = menu_driver_resolve();
if (!menu) if (!menu)
return -1; return -1;
@ -1554,20 +1555,15 @@ int cb_core_updater_list(void *data_, size_t len)
if (!data) if (!data)
return -1; return -1;
list = (file_list_t*)menu->menu_list->selection_buf; core_buf = (char*)malloc(len * sizeof(char));
if (!list) if (!core_buf)
return -1; return -1;
menu_list_clear(list); memcpy(core_buf, data, len * sizeof(char));
core_len = len;
menu->nonblocking_refresh = false;
print_buf_lines(list, data, len, MENU_FILE_DOWNLOAD_CORE);
menu_list_populate_generic(list, core_updater_list_path,
core_updater_list_label, core_updater_list_type);
driver.menu->nonblocking_refresh = false;
return 0; return 0;
} }
@ -1577,47 +1573,16 @@ int cb_core_updater_list(void *data_, size_t len)
static int deferred_push_core_updater_list(void *data, void *userdata, static int deferred_push_core_updater_list(void *data, void *userdata,
const char *path, const char *label, unsigned type) const char *path, const char *label, unsigned type)
{ {
#ifdef HAVE_NETWORKING file_list_t *list = (file_list_t*)data;
char url_path[PATH_MAX_LENGTH]; menu_list_clear(list);
strlcpy(core_updater_list_path, path, sizeof(core_updater_list_path)); print_buf_lines(list, core_buf, core_len, MENU_FILE_DOWNLOAD_CORE);
strlcpy(core_updater_list_label, label, sizeof(core_updater_list_label));
core_updater_list_type = type;
#endif
if (g_settings.network.buildbot_url[0] == '\0') if (core_buf)
{ free(core_buf);
file_list_t *list = (file_list_t*)data;
menu_list_clear(list); menu_list_populate_generic(list, core_updater_list_path,
#ifdef HAVE_NETWORKING core_updater_list_label, core_updater_list_type);
menu_list_push(list,
"Buildbot URL not configured.", "",
0, 0);
#else
menu_list_push(list,
"Network not available.", "",
0, 0);
#endif
menu_list_populate_generic(list, path, label, type);
return 0;
}
#ifdef HAVE_NETWORKING
rarch_main_command(RARCH_CMD_NETWORK_INIT);
fill_pathname_join(url_path, g_settings.network.buildbot_url,
".index", sizeof(url_path));
strlcat(url_path, "|cb_core_updater_list", sizeof(url_path));
msg_queue_clear(g_extern.http.msg_queue);
msg_queue_push(g_extern.http.msg_queue, url_path, 0, 1);
#endif
driver.menu->nonblocking_refresh = true;
return 0; return 0;
} }
@ -1882,7 +1847,7 @@ void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
if (strstr(label, "deferred_rdb_entry_detail")) if (strstr(label, "deferred_rdb_entry_detail"))
cbs->action_deferred_push = deferred_push_rdb_entry_detail; cbs->action_deferred_push = deferred_push_rdb_entry_detail;
else if (!strcmp(label, "core_updater_list")) else if (!strcmp(label, "deferred_core_updater_list"))
cbs->action_deferred_push = deferred_push_core_updater_list; cbs->action_deferred_push = deferred_push_core_updater_list;
else if (!strcmp(label, "history_list")) else if (!strcmp(label, "history_list"))
cbs->action_deferred_push = deferred_push_history_list; cbs->action_deferred_push = deferred_push_history_list;

View File

@ -30,6 +30,9 @@
#include "../input/input_remapping.h" #include "../input/input_remapping.h"
/* FIXME - Global variables, refactor */ /* FIXME - Global variables, refactor */
char core_updater_list_path[PATH_MAX_LENGTH];
char core_updater_list_label[PATH_MAX_LENGTH];
unsigned core_updater_list_type;
unsigned rdb_entry_start_game_selection_ptr; unsigned rdb_entry_start_game_selection_ptr;
size_t hack_shader_pass = 0; size_t hack_shader_pass = 0;
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
@ -253,6 +256,45 @@ static int action_ok_video_filter(const char *path,
0, idx); 0, idx);
} }
static int action_ok_core_updater_list(const char *path,
const char *label, unsigned type, size_t idx)
{
char url_path[PATH_MAX_LENGTH];
menu_handle_t *menu = menu_driver_resolve();
if (!menu)
return -1;
driver.menu->nonblocking_refresh = true;
(void)url_path;
#ifdef HAVE_NETWORKING
strlcpy(core_updater_list_path, path, sizeof(core_updater_list_path));
strlcpy(core_updater_list_label, label, sizeof(core_updater_list_label));
core_updater_list_type = type;
#endif
if (g_settings.network.buildbot_url[0] == '\0')
{
return -1;
}
#ifdef HAVE_NETWORKING
rarch_main_command(RARCH_CMD_NETWORK_INIT);
fill_pathname_join(url_path, g_settings.network.buildbot_url,
".index", sizeof(url_path));
strlcat(url_path, "|cb_core_updater_list", sizeof(url_path));
msg_queue_clear(g_extern.http.msg_queue);
msg_queue_push(g_extern.http.msg_queue, url_path, 0, 1);
#endif
return menu_list_push_stack_refresh(
menu->menu_list,
path, "deferred_core_updater_list", type, idx);
}
static int action_ok_remap_file(const char *path, static int action_ok_remap_file(const char *path,
const char *label, unsigned type, size_t idx) const char *label, unsigned type, size_t idx)
{ {
@ -846,7 +888,7 @@ static int action_ok_save_state(const char *path,
return generic_action_ok_command(RARCH_CMD_RESUME); return generic_action_ok_command(RARCH_CMD_RESUME);
} }
static int action_ok_core_updater_list(const char *path, static int action_ok_core_updater_download(const char *path,
const char *label, unsigned type, size_t idx) const char *label, unsigned type, size_t idx)
{ {
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
@ -1127,6 +1169,8 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
cbs->action_ok = action_ok_video_filter; cbs->action_ok = action_ok_video_filter;
else if (!strcmp(label, "remap_file_load")) else if (!strcmp(label, "remap_file_load"))
cbs->action_ok = action_ok_remap_file; cbs->action_ok = action_ok_remap_file;
else if (!strcmp(label, "core_updater_list"))
cbs->action_ok = action_ok_core_updater_list;
else if (!strcmp(label, "video_shader_parameters") || else if (!strcmp(label, "video_shader_parameters") ||
!strcmp(label, "video_shader_preset_parameters") !strcmp(label, "video_shader_preset_parameters")
) )
@ -1154,7 +1198,6 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
) )
cbs->action_ok = action_ok_push_content_list; cbs->action_ok = action_ok_push_content_list;
else if (!strcmp(label, "history_list") || else if (!strcmp(label, "history_list") ||
!strcmp(label, "core_updater_list") ||
!strcmp(label, "cursor_manager_list") || !strcmp(label, "cursor_manager_list") ||
!strcmp(label, "database_manager_list") || !strcmp(label, "database_manager_list") ||
(setting && setting->browser_selection_type == ST_DIR) (setting && setting->browser_selection_type == ST_DIR)
@ -1229,7 +1272,7 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
return; return;
break; break;
case MENU_FILE_DOWNLOAD_CORE: case MENU_FILE_DOWNLOAD_CORE:
cbs->action_ok = action_ok_core_updater_list; cbs->action_ok = action_ok_core_updater_download;
break; break;
case MENU_FILE_DOWNLOAD_CORE_INFO: case MENU_FILE_DOWNLOAD_CORE_INFO:
break; break;