Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index file for thumbnails (do not merge yet) #17521

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
470 changes: 463 additions & 7 deletions core_updater_list.c

Large diffs are not rendered by default.

55 changes: 53 additions & 2 deletions core_updater_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@

RETRO_BEGIN_DECLS

/* Get core updater list */
enum updater_list_status
{
UPDATER_LIST_BEGIN = 0,
UPDATER_LIST_WAIT,
UPDATER_LIST_END
};

/* Defines all possible 'types' of core
* updater list - corresponds to core
* delivery method:
Expand All @@ -51,7 +59,7 @@ typedef struct
unsigned year;
unsigned month;
unsigned day;
} core_updater_list_date_t;
} updater_list_date_t;

/* Holds all info related to a core
* file on the buildbot */
Expand All @@ -64,7 +72,7 @@ typedef struct
char *display_name;
char *description;
struct string_list *licenses_list;
core_updater_list_date_t date; /* unsigned alignment */
updater_list_date_t date; /* unsigned alignment */
uint32_t crc;
bool is_experimental;
} core_updater_list_entry_t;
Expand All @@ -73,6 +81,17 @@ typedef struct
* members */
typedef struct core_updater_list core_updater_list_t;


typedef struct
{
char *remote_filename;
char *local_filename;
updater_list_date_t date; /* unsigned alignment */
uint32_t crc;
} thumbnail_updater_list_entry_t;

typedef struct thumbnail_updater_list thumbnail_updater_list_t;

/**************************************/
/* Initialisation / De-Initialisation */
/**************************************/
Expand All @@ -89,6 +108,11 @@ void core_updater_list_reset(core_updater_list_t *core_list);
/* Frees specified core updater list */
void core_updater_list_free(core_updater_list_t *core_list);

/* Thumbnail counterparts */
thumbnail_updater_list_t *thumbnail_updater_list_init(const char *system);
void thumbnail_updater_list_reset(thumbnail_updater_list_t *thumbnail_list);
void thumbnail_updater_list_free(thumbnail_updater_list_t *thumbnail_list);

/***************/
/* Cached List */
/***************/
Expand All @@ -104,6 +128,11 @@ core_updater_list_t *core_updater_list_get_cached(void);
/* Frees cached core updater list */
void core_updater_list_free_cached(void);

/* Thumbnail counterparts */
bool thumbnail_updater_list_init_cached(const char *system);
thumbnail_updater_list_t *thumbnail_updater_list_get_cached(const char *system);
bool thumbnail_updater_list_is_empty(const char* system);

/***********/
/* Getters */
/***********/
Expand Down Expand Up @@ -140,6 +169,24 @@ bool core_updater_list_get_core(
const char *local_core_path,
const core_updater_list_entry_t **entry);

/* Thumbnail equivalents */
size_t thumbnail_updater_list_size(thumbnail_updater_list_t *thumbnail_list);

bool thumbnail_updater_list_get_index(
thumbnail_updater_list_t *thumbnail_list,
size_t idx,
const thumbnail_updater_list_entry_t **entry);

bool thumbnail_updater_list_get_filename(
thumbnail_updater_list_t *thumbnail_list,
const char *remote_filename,
const thumbnail_updater_list_entry_t **entry);

bool thumbnail_updater_list_get_matching_file(
thumbnail_updater_list_t *thumbnail_list,
const char *local_thumbnail_path,
const thumbnail_updater_list_entry_t **entry);

/***********/
/* Setters */
/***********/
Expand All @@ -165,6 +212,10 @@ bool core_updater_list_parse_pfd_data(
const char *path_libretro_info,
const struct string_list *pfd_cores);

bool thumbnail_updater_list_parse_network_data(
thumbnail_updater_list_t *thumbnail_list,
const char *data, size_t len);

RETRO_END_DECLS

#endif
1 change: 0 additions & 1 deletion file_path_special.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ RETRO_BEGIN_DECLS
#define FILE_PATH_RETROACHIEVEMENTS_URL "http://i.retroachievements.org"
#define FILE_PATH_LOBBY_LIBRETRO_URL "http://lobby.libretro.com/"
#define FILE_PATH_CORE_THUMBNAILS_URL "http://thumbnails.libretro.com"
#define FILE_PATH_CORE_THUMBNAILPACKS_URL "http://thumbnailpacks.libretro.com"
#define FILE_PATH_SHADERS_GLSL_ZIP "shaders_glsl.zip"
#define FILE_PATH_SHADERS_SLANG_ZIP "shaders_slang.zip"
#define FILE_PATH_SHADERS_CG_ZIP "shaders_cg.zip"
Expand Down
8 changes: 7 additions & 1 deletion gfx/gfx_thumbnail.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ void gfx_thumbnail_request(
{
enum playlist_thumbnail_name_flags curr_flag;
static char last_img_name[PATH_MAX_LENGTH] = {0};
const char *db_name = NULL;
settings_t *settings = config_get_ptr();
if (!playlist)
goto end;
Expand Down Expand Up @@ -372,7 +373,12 @@ void gfx_thumbnail_request(
/* Trigger thumbnail download *
* Note: download will grab all 3 possible thumbnails, no matter
* what left/right thumbnails are set at the moment */
task_push_pl_entry_thumbnail_download(path_data->system, playlist,
if (!string_is_empty(path_data->content_db_name))
db_name = path_data->content_db_name;
else
db_name = path_data->system;

task_push_pl_entry_thumbnail_download(db_name, playlist,
(unsigned)idx, false, true);
}
#endif
Expand Down
10 changes: 9 additions & 1 deletion intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -15207,6 +15207,14 @@ MSG_HASH(
MSG_NO_THUMBNAIL_DOWNLOAD_POSSIBLE,
"All possible thumbnail downloads were already tried for this playlist entry."
)
MSG_HASH(
MSG_FETCHING_THUMBNAIL_LIST,
"Fetching list of thumbnails on server..."
)
MSG_HASH(
MSG_THUMBNAIL_LIST_FAILED,
"Failed to retrieve thumbnail list!"
)
MSG_HASH(
MSG_PRESS_AGAIN_TO_QUIT,
"Press again to quit..."
Expand Down Expand Up @@ -16690,4 +16698,4 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_GAME_AI,
"Show the 'Game AI' option."
)
#endif
#endif
2 changes: 2 additions & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ enum msg_hash_enums
MSG_TOGGLE_CONTENT_METADATA,
MSG_NO_THUMBNAIL_AVAILABLE,
MSG_NO_THUMBNAIL_DOWNLOAD_POSSIBLE,
MSG_FETCHING_THUMBNAIL_LIST,
MSG_THUMBNAIL_LIST_FAILED,
MSG_PRESS_AGAIN_TO_QUIT,
MSG_BLUETOOTH_PAIRING_REMOVED,
MSG_BLUETOOTH_SCAN_COMPLETE,
Expand Down
25 changes: 9 additions & 16 deletions tasks/task_core_updater.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "../msg_hash.h"
#include "../verbosity.h"
#include "../core_updater_list.h"
#include "../file_path_special.h"

#if defined(ANDROID)
#include "../file_path_special.h"
Expand All @@ -48,20 +49,12 @@
#include "../menu/menu_driver.h"
#endif

/* Get core updater list */
enum core_updater_list_status
{
CORE_UPDATER_LIST_BEGIN = 0,
CORE_UPDATER_LIST_WAIT,
CORE_UPDATER_LIST_END
};

typedef struct core_updater_list_handle
{
core_updater_list_t* core_list;
retro_task_t *http_task;
http_transfer_data_t *http_data;
enum core_updater_list_status status;
enum updater_list_status status;
bool refresh_menu;
bool http_task_finished;
bool http_task_complete;
Expand Down Expand Up @@ -299,7 +292,7 @@ static void task_core_updater_get_list_handler(retro_task_t *task)

switch (list_handle->status)
{
case CORE_UPDATER_LIST_BEGIN:
case UPDATER_LIST_BEGIN:
{
char buildbot_url[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
Expand All @@ -320,7 +313,7 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
fill_pathname_join_special(
buildbot_url,
net_buildbot_url,
".index-extended",
FILE_PATH_INDEX_EXTENDED_URL,
sizeof(buildbot_url));

tmp_url = strdup(buildbot_url);
Expand Down Expand Up @@ -351,10 +344,10 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
cb_http_task_core_updater_get_list, transf);

/* Start waiting for HTTP transfer to complete */
list_handle->status = CORE_UPDATER_LIST_WAIT;
list_handle->status = UPDATER_LIST_WAIT;
}
break;
case CORE_UPDATER_LIST_WAIT:
case UPDATER_LIST_WAIT:
{
/* If HTTP task is NULL, then it either finished
* or an error occurred - in either case,
Expand All @@ -381,10 +374,10 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
/* Wait for task_push_http_transfer_file()
* callback to trigger */
if (list_handle->http_task_complete)
list_handle->status = CORE_UPDATER_LIST_END;
list_handle->status = UPDATER_LIST_END;
}
break;
case CORE_UPDATER_LIST_END:
case UPDATER_LIST_END:
{
settings_t *settings = config_get_ptr();

Expand Down Expand Up @@ -479,7 +472,7 @@ void *task_push_get_core_updater_list(
list_handle->http_task_complete = false;
list_handle->http_task_success = false;
list_handle->http_data = NULL;
list_handle->status = CORE_UPDATER_LIST_BEGIN;
list_handle->status = UPDATER_LIST_BEGIN;

/* Concurrent downloads of the buildbot core listing
* to the same core_updater_list_t object are not
Expand Down
Loading
Loading