mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
(task_http.c) Cleanups
This commit is contained in:
parent
e255204158
commit
d9d1c13612
@ -22,8 +22,9 @@
|
|||||||
#include <net/net_compat.h>
|
#include <net/net_compat.h>
|
||||||
#include <retro_timers.h>
|
#include <retro_timers.h>
|
||||||
|
|
||||||
#include "../verbosity.h"
|
#ifdef RARCH_INTERNAL
|
||||||
#include "../gfx/video_display_server.h"
|
#include "../gfx/video_display_server.h"
|
||||||
|
#endif
|
||||||
#include "task_file_transfer.h"
|
#include "task_file_transfer.h"
|
||||||
#include "tasks_internal.h"
|
#include "tasks_internal.h"
|
||||||
|
|
||||||
@ -97,7 +98,6 @@ static int cb_http_conn_default(void *data_, size_t len)
|
|||||||
|
|
||||||
if (!http->handle)
|
if (!http->handle)
|
||||||
{
|
{
|
||||||
RARCH_ERR("[http] Could not create new HTTP session handle.\n");
|
|
||||||
http->error = true;
|
http->error = true;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -238,9 +238,10 @@ static bool task_http_retriever(retro_task_t *task, void *data)
|
|||||||
|
|
||||||
static void http_transfer_progress_cb(retro_task_t *task)
|
static void http_transfer_progress_cb(retro_task_t *task)
|
||||||
{
|
{
|
||||||
if (!task)
|
#ifdef RARCH_INTERNAL
|
||||||
return;
|
if (task)
|
||||||
video_display_server_set_window_progress(task->progress, task->finished);
|
video_display_server_set_window_progress(task->progress, task->finished);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* task_push_http_transfer_generic(
|
static void* task_push_http_transfer_generic(
|
||||||
@ -254,9 +255,6 @@ static void* task_push_http_transfer_generic(
|
|||||||
retro_task_t *t = NULL;
|
retro_task_t *t = NULL;
|
||||||
http_handle_t *http = NULL;
|
http_handle_t *http = NULL;
|
||||||
|
|
||||||
if (string_is_empty(url))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
tmp[0] = '\0';
|
tmp[0] = '\0';
|
||||||
|
|
||||||
find_data.func = task_http_finder;
|
find_data.func = task_http_finder;
|
||||||
@ -264,10 +262,7 @@ static void* task_push_http_transfer_generic(
|
|||||||
|
|
||||||
/* Concurrent download of the same file is not allowed */
|
/* Concurrent download of the same file is not allowed */
|
||||||
if (task_queue_find(&find_data))
|
if (task_queue_find(&find_data))
|
||||||
{
|
|
||||||
RARCH_LOG("[http] '%s' is already being downloaded.\n", url);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -305,10 +300,8 @@ static void* task_push_http_transfer_generic(
|
|||||||
s = url;
|
s = url;
|
||||||
|
|
||||||
if (strstr(s, ".index"))
|
if (strstr(s, ".index"))
|
||||||
{
|
|
||||||
snprintf(tmp, sizeof(tmp), "%s %s",
|
snprintf(tmp, sizeof(tmp), "%s %s",
|
||||||
msg_hash_to_str(MSG_DOWNLOADING), msg_hash_to_str(MSG_INDEX_FILE));
|
msg_hash_to_str(MSG_DOWNLOADING), msg_hash_to_str(MSG_INDEX_FILE));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
snprintf(tmp, sizeof(tmp), "%s '%s'",
|
snprintf(tmp, sizeof(tmp), "%s '%s'",
|
||||||
msg_hash_to_str(MSG_DOWNLOADING), s);
|
msg_hash_to_str(MSG_DOWNLOADING), s);
|
||||||
@ -332,22 +325,18 @@ void* task_push_http_transfer(const char *url, bool mute,
|
|||||||
const char *type,
|
const char *type,
|
||||||
retro_task_callback_t cb, void *user_data)
|
retro_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
struct http_connection_t *conn;
|
if (string_is_empty(url))
|
||||||
|
return NULL;
|
||||||
conn = net_http_connection_new(url, "GET", NULL);
|
return task_push_http_transfer_generic(net_http_connection_new(url, "GET", NULL), url, mute, type, cb, user_data);
|
||||||
|
|
||||||
return task_push_http_transfer_generic(conn, url, mute, type, cb, user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void* task_push_http_post_transfer(const char *url,
|
void* task_push_http_post_transfer(const char *url,
|
||||||
const char *post_data, bool mute,
|
const char *post_data, bool mute,
|
||||||
const char *type, retro_task_callback_t cb, void *user_data)
|
const char *type, retro_task_callback_t cb, void *user_data)
|
||||||
{
|
{
|
||||||
struct http_connection_t *conn;
|
if (string_is_empty(url))
|
||||||
|
return NULL;
|
||||||
conn = net_http_connection_new(url, "POST", post_data);
|
return task_push_http_transfer_generic(net_http_connection_new(url, "POST", post_data),
|
||||||
|
|
||||||
return task_push_http_transfer_generic(conn,
|
|
||||||
url, mute, type, cb, user_data);
|
url, mute, type, cb, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user