Skip to content

Commit 893b0d1

Browse files
authored
Cloud Sync (libretro#15548)
* cloud sync - algorithm and abstract cloud storage API * WebDAV cloud sync driver, and associated net_http improvements * Cloud sync settings menu
1 parent 45af11e commit 893b0d1

30 files changed

+2667
-26
lines changed

configuration.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,7 @@ static struct config_array_setting *populate_settings_array(settings_t *settings
14901490
SETTING_ARRAY("bluetooth_driver", settings->arrays.bluetooth_driver, false, NULL, true);
14911491
SETTING_ARRAY("wifi_driver", settings->arrays.wifi_driver, false, NULL, true);
14921492
SETTING_ARRAY("location_driver", settings->arrays.location_driver,false, NULL, true);
1493+
SETTING_ARRAY("cloud_sync_driver", settings->arrays.cloud_sync_driver, false, NULL, true);
14931494
#ifdef HAVE_MENU
14941495
SETTING_ARRAY("menu_driver", settings->arrays.menu_driver, false, NULL, true);
14951496
#endif
@@ -1516,6 +1517,9 @@ static struct config_array_setting *populate_settings_array(settings_t *settings
15161517
SETTING_ARRAY("midi_driver", settings->arrays.midi_driver, false, NULL, true);
15171518
SETTING_ARRAY("midi_input", settings->arrays.midi_input, true, DEFAULT_MIDI_INPUT, true);
15181519
SETTING_ARRAY("midi_output", settings->arrays.midi_output, true, DEFAULT_MIDI_OUTPUT, true);
1520+
SETTING_ARRAY("webdav_url", settings->arrays.webdav_url, false, NULL, true);
1521+
SETTING_ARRAY("webdav_username", settings->arrays.webdav_username, false, NULL, true);
1522+
SETTING_ARRAY("webdav_password", settings->arrays.webdav_password, false, NULL, true);
15191523
SETTING_ARRAY("youtube_stream_key", settings->arrays.youtube_stream_key, true, NULL, true);
15201524
SETTING_ARRAY("twitch_stream_key", settings->arrays.twitch_stream_key, true, NULL, true);
15211525
SETTING_ARRAY("facebook_stream_key", settings->arrays.facebook_stream_key, true, NULL, true);
@@ -1848,6 +1852,8 @@ static struct config_bool_setting *populate_settings_bool(
18481852
SETTING_BOOL("core_updater_show_experimental_cores", &settings->bools.network_buildbot_show_experimental_cores, true, DEFAULT_NETWORK_BUILDBOT_SHOW_EXPERIMENTAL_CORES, false);
18491853
SETTING_BOOL("core_updater_auto_backup", &settings->bools.core_updater_auto_backup, true, DEFAULT_CORE_UPDATER_AUTO_BACKUP, false);
18501854
SETTING_BOOL("camera_allow", &settings->bools.camera_allow, true, false, false);
1855+
SETTING_BOOL("cloud_sync_enable", &settings->bools.cloud_sync_enable, true, false, false);
1856+
SETTING_BOOL("cloud_sync_destructive", &settings->bools.cloud_sync_destructive, true, false, false);
18511857
SETTING_BOOL("discord_allow", &settings->bools.discord_enable, true, false, false);
18521858
#if defined(VITA)
18531859
SETTING_BOOL("input_backtouch_enable", &settings->bools.input_backtouch_enable, false, DEFAULT_INPUT_BACKTOUCH_ENABLE, false);

configuration.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ typedef struct settings
427427
char wifi_driver[32];
428428
char led_driver[32];
429429
char location_driver[32];
430+
char cloud_sync_driver[32];
430431
char menu_driver[32];
431432
char cheevos_username[32];
432433
char cheevos_password[256];
@@ -460,6 +461,10 @@ typedef struct settings
460461

461462
char translation_service_url[2048];
462463

464+
char webdav_url[255];
465+
char webdav_username[255];
466+
char webdav_password[255];
467+
463468
char youtube_stream_key[PATH_MAX_LENGTH];
464469
char twitch_stream_key[PATH_MAX_LENGTH];
465470
char facebook_stream_key[PATH_MAX_LENGTH];
@@ -899,6 +904,10 @@ typedef struct settings
899904
bool steam_rich_presence_enable;
900905
#endif
901906

907+
/* Cloud Sync */
908+
bool cloud_sync_enable;
909+
bool cloud_sync_destructive;
910+
902911
/* Misc. */
903912
bool discord_enable;
904913
bool threaded_data_runloop_enable;

griffin/griffin.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,3 +1621,12 @@ STEAM INTEGRATION USING MIST
16211621
#ifdef HAVE_PRESENCE
16221622
#include "../network/presence.c"
16231623
#endif
1624+
1625+
/*============================================================
1626+
CLOUD SYNC
1627+
============================================================ */
1628+
#ifdef HAVE_CLOUDSYNC
1629+
#include "../tasks/task_cloudsync.c"
1630+
#include "../network/cloud_sync_driver.c"
1631+
#include "../network/cloud_sync/webdav.c"
1632+
#endif

intl/msg_hash_lbl.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,10 @@ MSG_HASH(
14091409
MENU_ENUM_LABEL_DEFERRED_SAVING_SETTINGS_LIST,
14101410
"deferred_saving_settings_list"
14111411
)
1412+
MSG_HASH(
1413+
MENU_ENUM_LABEL_DEFERRED_CLOUD_SYNC_SETTINGS_LIST,
1414+
"deferred_cloud_sync_settings_list"
1415+
)
14121416
MSG_HASH(
14131417
MENU_ENUM_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST,
14141418
"deferred_thumbnails_updater_list"
@@ -3483,6 +3487,34 @@ MSG_HASH(
34833487
MENU_ENUM_LABEL_SAVING_SETTINGS,
34843488
"saving_settings"
34853489
)
3490+
MSG_HASH(
3491+
MENU_ENUM_LABEL_CLOUD_SYNC_SETTINGS,
3492+
"cloud_sync_settings"
3493+
)
3494+
MSG_HASH(
3495+
MENU_ENUM_LABEL_CLOUD_SYNC_ENABLE,
3496+
"cloud_sync_enable"
3497+
)
3498+
MSG_HASH(
3499+
MENU_ENUM_LABEL_CLOUD_SYNC_DESTRUCTIVE,
3500+
"cloud_sync_destructive"
3501+
)
3502+
MSG_HASH(
3503+
MENU_ENUM_LABEL_CLOUD_SYNC_DRIVER,
3504+
"cloud_sync_driver"
3505+
)
3506+
MSG_HASH(
3507+
MENU_ENUM_LABEL_CLOUD_SYNC_URL,
3508+
"cloud_sync_url"
3509+
)
3510+
MSG_HASH(
3511+
MENU_ENUM_LABEL_CLOUD_SYNC_USERNAME,
3512+
"cloud_sync_username"
3513+
)
3514+
MSG_HASH(
3515+
MENU_ENUM_LABEL_CLOUD_SYNC_PASSWORD,
3516+
"cloud_sync_password"
3517+
)
34863518
MSG_HASH(
34873519
MENU_ENUM_LABEL_SCAN_DIRECTORY,
34883520
"scan_directory"

intl/msg_hash_us.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,62 @@ MSG_HASH(
12041204
MENU_ENUM_SUBLABEL_SAVING_SETTINGS,
12051205
"Change saving settings."
12061206
)
1207+
MSG_HASH(
1208+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_SETTINGS,
1209+
"Cloud Sync"
1210+
)
1211+
MSG_HASH(
1212+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_SETTINGS,
1213+
"Change cloud sync settings."
1214+
)
1215+
MSG_HASH(
1216+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_ENABLE,
1217+
"Enable Cloud Sync"
1218+
)
1219+
MSG_HASH(
1220+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_ENABLE,
1221+
"Attempt to sync configs, sram, and states to a cloud storage provider."
1222+
)
1223+
MSG_HASH(
1224+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_DESTRUCTIVE,
1225+
"Destructive Cloud Sync"
1226+
)
1227+
MSG_HASH(
1228+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_DESTRUCTIVE,
1229+
"When disabled, files are moved to a backup folder before being overwritten or deleted."
1230+
)
1231+
MSG_HASH(
1232+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_DRIVER,
1233+
"Cloud Sync Backend"
1234+
)
1235+
MSG_HASH(
1236+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_DRIVER,
1237+
"Which cloud storage network protocol to use."
1238+
)
1239+
MSG_HASH(
1240+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_URL,
1241+
"Cloud Storage URL"
1242+
)
1243+
MSG_HASH(
1244+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_URL,
1245+
"The URL for the API entry point to the cloud storage service."
1246+
)
1247+
MSG_HASH(
1248+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_USERNAME,
1249+
"Username"
1250+
)
1251+
MSG_HASH(
1252+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_USERNAME,
1253+
"Your username for your cloud storage account."
1254+
)
1255+
MSG_HASH(
1256+
MENU_ENUM_LABEL_VALUE_CLOUD_SYNC_PASSWORD,
1257+
"Password"
1258+
)
1259+
MSG_HASH(
1260+
MENU_ENUM_SUBLABEL_CLOUD_SYNC_PASSWORD,
1261+
"Your password for your cloud storage account."
1262+
)
12071263
MSG_HASH(
12081264
MENU_ENUM_LABEL_VALUE_LOGGING_SETTINGS,
12091265
"Logging"

libretro-common/include/net/net_http.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ void net_http_connection_set_user_agent(struct http_connection_t *conn, const ch
5151

5252
void net_http_connection_set_headers(struct http_connection_t *conn, const char *headers);
5353

54+
void net_http_connection_set_content(struct http_connection_t *conn, const char *content_type,
55+
size_t content_length, const void *content);
56+
5457
const char *net_http_connection_url(struct http_connection_t *conn);
5558

5659
const char* net_http_connection_method(struct http_connection_t* conn);
@@ -93,6 +96,17 @@ int net_http_status(struct http_t *state);
9396
**/
9497
bool net_http_error(struct http_t *state);
9598

99+
/**
100+
* net_http_headers:
101+
*
102+
* Leaf function.
103+
*
104+
* @return the response headers. The returned buffer is owned by the
105+
* caller of net_http_new; it is not freed by net_http_delete.
106+
* If the status is not 20x and accept_error is false, it returns NULL.
107+
**/
108+
struct string_list *net_http_headers(struct http_t *state);
109+
96110
/**
97111
* net_http_data:
98112
*

0 commit comments

Comments
 (0)