mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
[discord] **not-working** download the connecting user avatar seems something special needs to be done for https transfers on windows at least
see: https://github.com/libretro/RetroArch/issues/7451
This commit is contained in:
parent
583273d81b
commit
a6e6ccc244
@ -39,8 +39,12 @@
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#include "../../menu/widgets/menu_input_dialog.h"
|
||||
#include "../../menu/menu_cbs.h"
|
||||
#endif
|
||||
|
||||
#include <net/net_http.h>
|
||||
#include "../network/net_http_special.h"
|
||||
#include "../tasks/tasks_internal.h"
|
||||
|
||||
static int FrustrationLevel = 0;
|
||||
|
||||
@ -55,6 +59,8 @@ struct netplay_room *room;
|
||||
|
||||
static char user_id[128];
|
||||
|
||||
static char cdn_url[] = "https://cdn.discordapp.com/avatars";
|
||||
|
||||
DiscordRichPresence discord_presence;
|
||||
|
||||
static void handle_discord_ready(const DiscordUser* connectedUser)
|
||||
@ -113,13 +119,29 @@ static void handle_discord_join_response(void *ignore, const char *line)
|
||||
|
||||
static void handle_discord_join_request(const DiscordUser* request)
|
||||
{
|
||||
RARCH_LOG("[Discord] join request from %s#%s - %s\n",
|
||||
static char url[PATH_MAX_LENGTH];
|
||||
static char url_encoded[PATH_MAX_LENGTH];
|
||||
|
||||
RARCH_LOG("[Discord] join request from %s#%s - %s %s\n",
|
||||
request->username,
|
||||
request->discriminator,
|
||||
request->userId);
|
||||
request->userId,
|
||||
request->avatar);
|
||||
|
||||
strlcpy(user_id, request->userId, sizeof(user_id));
|
||||
|
||||
snprintf(url, sizeof(url), "%s/%s/%s.png", cdn_url,request->userId, request->avatar);
|
||||
net_http_urlencode_full(url_encoded, url, sizeof(url_encoded));
|
||||
|
||||
RARCH_LOG("[Discord] downloading avatar from: %s\n", url_encoded);
|
||||
|
||||
file_transfer_t *transf = NULL;
|
||||
transf = (file_transfer_t*)calloc(1, sizeof(*transf));
|
||||
transf->enum_idx = MENU_ENUM_LABEL_CB_DISCORD_AVATAR;
|
||||
strlcpy(transf->path, request->avatar, sizeof(transf->path));
|
||||
|
||||
task_push_http_transfer(url_encoded, true, NULL, cb_generic_download, transf);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
char buf[PATH_MAX_LENGTH];
|
||||
menu_input_ctx_line_t line;
|
||||
|
@ -338,6 +338,31 @@ void fill_pathname_application_special(char *s,
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS:
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
char *s2 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
s1[0] = s2[0] = '\0';
|
||||
|
||||
fill_pathname_join(s1,
|
||||
settings->paths.directory_thumbnails,
|
||||
"discord",
|
||||
len);
|
||||
fill_pathname_join(s2,
|
||||
s1, "avatars",
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
fill_pathname_slash(s2,
|
||||
PATH_MAX_LENGTH * sizeof(char)
|
||||
);
|
||||
strlcpy(s, s2, len);
|
||||
free(s1);
|
||||
free(s2);
|
||||
}
|
||||
break;
|
||||
|
||||
case APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES:
|
||||
{
|
||||
char *s1 = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
@ -111,7 +111,8 @@ enum application_special_type
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_ZARCH,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_ZARCH_FONT,
|
||||
APPLICATION_SPECIAL_DIRECTORY_ASSETS_ZARCH_ICONS,
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES,
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -3343,7 +3343,7 @@ static void cb_generic_dir_download(void *task_data,
|
||||
}
|
||||
|
||||
/* expects http_transfer_t*, file_transfer_t* */
|
||||
static void cb_generic_download(void *task_data,
|
||||
void cb_generic_download(void *task_data,
|
||||
void *user_data, const char *err)
|
||||
{
|
||||
char output_path[PATH_MAX_LENGTH];
|
||||
@ -3359,6 +3359,7 @@ static void cb_generic_download(void *task_data,
|
||||
goto finish;
|
||||
|
||||
output_path[0] = '\0';
|
||||
char buf[PATH_MAX_LENGTH];;
|
||||
|
||||
/* we have to determine dir_path at the time of writting or else
|
||||
* we'd run into races when the user changes the setting during an
|
||||
@ -3423,6 +3424,15 @@ static void cb_generic_download(void *task_data,
|
||||
case MENU_ENUM_LABEL_CB_LAKKA_DOWNLOAD:
|
||||
dir_path = LAKKA_UPDATE_DIR;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CB_DISCORD_AVATAR:
|
||||
{
|
||||
fill_pathname_application_special(buf,
|
||||
PATH_MAX_LENGTH * sizeof(char),
|
||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_DISCORD_AVATARS);
|
||||
dir_path = buf;
|
||||
RARCH_LOG("Path: %s\n", dir_path);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
RARCH_WARN("Unknown transfer type '%s' bailing out.\n",
|
||||
msg_hash_to_str(transf->enum_idx));
|
||||
|
@ -286,6 +286,10 @@ void menu_cbs_init(void *data,
|
||||
|
||||
int menu_cbs_exit(void);
|
||||
|
||||
void cb_generic_download(void *task_data,
|
||||
void *user_data, const char *err);
|
||||
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -1932,6 +1932,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_CB_UPDATE_SHADERS_CG,
|
||||
MENU_ENUM_LABEL_CB_UPDATE_SHADERS_GLSL,
|
||||
MENU_ENUM_LABEL_CB_UPDATE_SHADERS_SLANG,
|
||||
MENU_ENUM_LABEL_CB_DISCORD_AVATAR,
|
||||
|
||||
/* Sublabels */
|
||||
MENU_ENUM_SUBLABEL_MIXER_ACTION_PLAY,
|
||||
|
Loading…
x
Reference in New Issue
Block a user