From 90a6932b53bad8b9d100780de0c88ab479ae4d5c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 24 Jun 2015 17:42:31 +0200 Subject: [PATCH] Implement 'Update Databases' --- menu/cbs/menu_cbs_ok.c | 15 +++++++++++++++ tasks/task_http.c | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 99db8bcfa3..9774ab15d1 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1267,6 +1267,8 @@ static int action_ok_download_generic(const char *path, path = "cheats.zip"; else if (!strcmp(type_msg, "cb_update_overlays")) path = "overlays.zip"; + else if (!strcmp(type_msg, "cb_update_databases")) + path = "database-rdb.zip"; else strlcpy(s, settings->network.buildbot_url, sizeof(s)); @@ -1317,6 +1319,16 @@ static int action_ok_update_overlays(const char *path, return 0; } +static int action_ok_update_databases(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ +#ifdef HAVE_NETWORKING + action_ok_download_generic(path, label, type, idx, entry_idx, + "cb_update_databases"); +#endif + return 0; +} + static int action_ok_update_cheats(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -1713,6 +1725,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_UPDATE_OVERLAYS: cbs->action_ok = action_ok_update_overlays; break; + case MENU_LABEL_UPDATE_DATABASES: + cbs->action_ok = action_ok_update_databases; + break; case MENU_LABEL_UPDATE_CHEATS: cbs->action_ok = action_ok_update_cheats; break; diff --git a/tasks/task_http.c b/tasks/task_http.c index fa3ccb4055..6323feeb38 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -32,6 +32,7 @@ #define CB_UPDATE_AUTOCONFIG_PROFILES 0x28ada67dU #define CB_UPDATE_CHEATS 0xc360fec3U #define CB_UPDATE_OVERLAYS 0x699009a0U +#define CB_UPDATE_DATABASES 0x931eb8d3U extern char core_updater_path[PATH_MAX_LENGTH]; @@ -142,6 +143,12 @@ static int cb_update_autoconfig_profiles(void *data, size_t len) return cb_generic_download(data, len, settings->input.autoconfig_dir); } +static int cb_update_databases(void *data, size_t len) +{ + settings_t *settings = config_get_ptr(); + return cb_generic_download(data, len, settings->content_database); +} + static int cb_update_overlays(void *data, size_t len) { global_t *global = global_get_ptr(); @@ -231,6 +238,9 @@ static int cb_http_conn_default(void *data_, size_t len) case CB_UPDATE_CHEATS: http->cb = &cb_update_cheats; break; + case CB_UPDATE_DATABASES: + http->cb = &cb_update_databases; + break; case CB_UPDATE_OVERLAYS: http->cb = &cb_update_overlays; break;