Skip to content

Commit a5f1b60

Browse files
committed
Index file for thumbnails
Add the function to retrieve an .index-extended file for thumbnail repositories, similar to core updater. Use the list to determine if the download should be attempted or not. For now, fall back to previous method if index can not be retrieved.
1 parent f1e3b83 commit a5f1b60

9 files changed

+945
-45
lines changed

core_updater_list.c

+463-7
Large diffs are not rendered by default.

core_updater_list.h

+53-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232

3333
RETRO_BEGIN_DECLS
3434

35+
/* Get core updater list */
36+
enum updater_list_status
37+
{
38+
UPDATER_LIST_BEGIN = 0,
39+
UPDATER_LIST_WAIT,
40+
UPDATER_LIST_END
41+
};
42+
3543
/* Defines all possible 'types' of core
3644
* updater list - corresponds to core
3745
* delivery method:
@@ -51,7 +59,7 @@ typedef struct
5159
unsigned year;
5260
unsigned month;
5361
unsigned day;
54-
} core_updater_list_date_t;
62+
} updater_list_date_t;
5563

5664
/* Holds all info related to a core
5765
* file on the buildbot */
@@ -64,7 +72,7 @@ typedef struct
6472
char *display_name;
6573
char *description;
6674
struct string_list *licenses_list;
67-
core_updater_list_date_t date; /* unsigned alignment */
75+
updater_list_date_t date; /* unsigned alignment */
6876
uint32_t crc;
6977
bool is_experimental;
7078
} core_updater_list_entry_t;
@@ -73,6 +81,17 @@ typedef struct
7381
* members */
7482
typedef struct core_updater_list core_updater_list_t;
7583

84+
85+
typedef struct
86+
{
87+
char *remote_filename;
88+
char *local_filename;
89+
updater_list_date_t date; /* unsigned alignment */
90+
uint32_t crc;
91+
} thumbnail_updater_list_entry_t;
92+
93+
typedef struct thumbnail_updater_list thumbnail_updater_list_t;
94+
7695
/**************************************/
7796
/* Initialisation / De-Initialisation */
7897
/**************************************/
@@ -89,6 +108,11 @@ void core_updater_list_reset(core_updater_list_t *core_list);
89108
/* Frees specified core updater list */
90109
void core_updater_list_free(core_updater_list_t *core_list);
91110

111+
/* Thumbnail counterparts */
112+
thumbnail_updater_list_t *thumbnail_updater_list_init(const char *system);
113+
void thumbnail_updater_list_reset(thumbnail_updater_list_t *thumbnail_list);
114+
void thumbnail_updater_list_free(thumbnail_updater_list_t *thumbnail_list);
115+
92116
/***************/
93117
/* Cached List */
94118
/***************/
@@ -104,6 +128,11 @@ core_updater_list_t *core_updater_list_get_cached(void);
104128
/* Frees cached core updater list */
105129
void core_updater_list_free_cached(void);
106130

131+
/* Thumbnail counterparts */
132+
bool thumbnail_updater_list_init_cached(const char *system);
133+
thumbnail_updater_list_t *thumbnail_updater_list_get_cached(const char *system);
134+
bool thumbnail_updater_list_is_empty(const char* system);
135+
107136
/***********/
108137
/* Getters */
109138
/***********/
@@ -140,6 +169,24 @@ bool core_updater_list_get_core(
140169
const char *local_core_path,
141170
const core_updater_list_entry_t **entry);
142171

172+
/* Thumbnail equivalents */
173+
size_t thumbnail_updater_list_size(thumbnail_updater_list_t *thumbnail_list);
174+
175+
bool thumbnail_updater_list_get_index(
176+
thumbnail_updater_list_t *thumbnail_list,
177+
size_t idx,
178+
const thumbnail_updater_list_entry_t **entry);
179+
180+
bool thumbnail_updater_list_get_filename(
181+
thumbnail_updater_list_t *thumbnail_list,
182+
const char *remote_filename,
183+
const thumbnail_updater_list_entry_t **entry);
184+
185+
bool thumbnail_updater_list_get_matching_file(
186+
thumbnail_updater_list_t *thumbnail_list,
187+
const char *local_thumbnail_path,
188+
const thumbnail_updater_list_entry_t **entry);
189+
143190
/***********/
144191
/* Setters */
145192
/***********/
@@ -165,6 +212,10 @@ bool core_updater_list_parse_pfd_data(
165212
const char *path_libretro_info,
166213
const struct string_list *pfd_cores);
167214

215+
bool thumbnail_updater_list_parse_network_data(
216+
thumbnail_updater_list_t *thumbnail_list,
217+
const char *data, size_t len);
218+
168219
RETRO_END_DECLS
169220

170221
#endif

file_path_special.h

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ RETRO_BEGIN_DECLS
7575
#define FILE_PATH_RETROACHIEVEMENTS_URL "http://i.retroachievements.org"
7676
#define FILE_PATH_LOBBY_LIBRETRO_URL "http://lobby.libretro.com/"
7777
#define FILE_PATH_CORE_THUMBNAILS_URL "http://thumbnails.libretro.com"
78-
#define FILE_PATH_CORE_THUMBNAILPACKS_URL "http://thumbnailpacks.libretro.com"
7978
#define FILE_PATH_SHADERS_GLSL_ZIP "shaders_glsl.zip"
8079
#define FILE_PATH_SHADERS_SLANG_ZIP "shaders_slang.zip"
8180
#define FILE_PATH_SHADERS_CG_ZIP "shaders_cg.zip"

gfx/gfx_thumbnail.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ void gfx_thumbnail_request(
332332
{
333333
enum playlist_thumbnail_name_flags curr_flag;
334334
static char last_img_name[PATH_MAX_LENGTH] = {0};
335+
const char *db_name = NULL;
335336
settings_t *settings = config_get_ptr();
336337
if (!playlist)
337338
goto end;
@@ -372,7 +373,12 @@ void gfx_thumbnail_request(
372373
/* Trigger thumbnail download *
373374
* Note: download will grab all 3 possible thumbnails, no matter
374375
* what left/right thumbnails are set at the moment */
375-
task_push_pl_entry_thumbnail_download(path_data->system, playlist,
376+
if (!string_is_empty(path_data->content_db_name))
377+
db_name = path_data->content_db_name;
378+
else
379+
db_name = path_data->system;
380+
381+
task_push_pl_entry_thumbnail_download(db_name, playlist,
376382
(unsigned)idx, false, true);
377383
}
378384
#endif

intl/msg_hash_us.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -15207,6 +15207,14 @@ MSG_HASH(
1520715207
MSG_NO_THUMBNAIL_DOWNLOAD_POSSIBLE,
1520815208
"All possible thumbnail downloads were already tried for this playlist entry."
1520915209
)
15210+
MSG_HASH(
15211+
MSG_FETCHING_THUMBNAIL_LIST,
15212+
"Fetching list of thumbnails on server..."
15213+
)
15214+
MSG_HASH(
15215+
MSG_THUMBNAIL_LIST_FAILED,
15216+
"Failed to retrieve thumbnail list!"
15217+
)
1521015218
MSG_HASH(
1521115219
MSG_PRESS_AGAIN_TO_QUIT,
1521215220
"Press again to quit..."
@@ -16690,4 +16698,4 @@ MSG_HASH(
1669016698
MENU_ENUM_SUBLABEL_QUICK_MENU_SHOW_GAME_AI,
1669116699
"Show the 'Game AI' option."
1669216700
)
16693-
#endif
16701+
#endif

msg_hash.h

+2
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ enum msg_hash_enums
444444
MSG_TOGGLE_CONTENT_METADATA,
445445
MSG_NO_THUMBNAIL_AVAILABLE,
446446
MSG_NO_THUMBNAIL_DOWNLOAD_POSSIBLE,
447+
MSG_FETCHING_THUMBNAIL_LIST,
448+
MSG_THUMBNAIL_LIST_FAILED,
447449
MSG_PRESS_AGAIN_TO_QUIT,
448450
MSG_BLUETOOTH_PAIRING_REMOVED,
449451
MSG_BLUETOOTH_SCAN_COMPLETE,

tasks/task_core_updater.c

+9-16
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "../msg_hash.h"
3838
#include "../verbosity.h"
3939
#include "../core_updater_list.h"
40+
#include "../file_path_special.h"
4041

4142
#if defined(ANDROID)
4243
#include "../file_path_special.h"
@@ -48,20 +49,12 @@
4849
#include "../menu/menu_driver.h"
4950
#endif
5051

51-
/* Get core updater list */
52-
enum core_updater_list_status
53-
{
54-
CORE_UPDATER_LIST_BEGIN = 0,
55-
CORE_UPDATER_LIST_WAIT,
56-
CORE_UPDATER_LIST_END
57-
};
58-
5952
typedef struct core_updater_list_handle
6053
{
6154
core_updater_list_t* core_list;
6255
retro_task_t *http_task;
6356
http_transfer_data_t *http_data;
64-
enum core_updater_list_status status;
57+
enum updater_list_status status;
6558
bool refresh_menu;
6659
bool http_task_finished;
6760
bool http_task_complete;
@@ -299,7 +292,7 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
299292

300293
switch (list_handle->status)
301294
{
302-
case CORE_UPDATER_LIST_BEGIN:
295+
case UPDATER_LIST_BEGIN:
303296
{
304297
char buildbot_url[PATH_MAX_LENGTH];
305298
settings_t *settings = config_get_ptr();
@@ -320,7 +313,7 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
320313
fill_pathname_join_special(
321314
buildbot_url,
322315
net_buildbot_url,
323-
".index-extended",
316+
FILE_PATH_INDEX_EXTENDED_URL,
324317
sizeof(buildbot_url));
325318

326319
tmp_url = strdup(buildbot_url);
@@ -351,10 +344,10 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
351344
cb_http_task_core_updater_get_list, transf);
352345

353346
/* Start waiting for HTTP transfer to complete */
354-
list_handle->status = CORE_UPDATER_LIST_WAIT;
347+
list_handle->status = UPDATER_LIST_WAIT;
355348
}
356349
break;
357-
case CORE_UPDATER_LIST_WAIT:
350+
case UPDATER_LIST_WAIT:
358351
{
359352
/* If HTTP task is NULL, then it either finished
360353
* or an error occurred - in either case,
@@ -381,10 +374,10 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
381374
/* Wait for task_push_http_transfer_file()
382375
* callback to trigger */
383376
if (list_handle->http_task_complete)
384-
list_handle->status = CORE_UPDATER_LIST_END;
377+
list_handle->status = UPDATER_LIST_END;
385378
}
386379
break;
387-
case CORE_UPDATER_LIST_END:
380+
case UPDATER_LIST_END:
388381
{
389382
settings_t *settings = config_get_ptr();
390383

@@ -479,7 +472,7 @@ void *task_push_get_core_updater_list(
479472
list_handle->http_task_complete = false;
480473
list_handle->http_task_success = false;
481474
list_handle->http_data = NULL;
482-
list_handle->status = CORE_UPDATER_LIST_BEGIN;
475+
list_handle->status = UPDATER_LIST_BEGIN;
483476

484477
/* Concurrent downloads of the buildbot core listing
485478
* to the same core_updater_list_t object are not

0 commit comments

Comments
 (0)