2016-12-02 18:56:29 -05:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 13:40:32 +01:00
|
|
|
* Copyright (C) 2016-2017 - Jean-André Santoni
|
2017-12-11 23:55:31 -08:00
|
|
|
* Copyright (C) 2017 - Andrés Suárez
|
2016-12-02 18:56:29 -05:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-02-04 09:20:41 +01:00
|
|
|
#include <lists/file_list.h>
|
2016-12-02 18:56:29 -05:00
|
|
|
#include <string/stdstring.h>
|
2017-02-27 21:24:34 -05:00
|
|
|
#include "../paths.h"
|
2016-12-02 18:56:29 -05:00
|
|
|
|
2019-01-20 02:17:43 +01:00
|
|
|
#include "task_file_transfer.h"
|
2016-12-02 18:56:29 -05:00
|
|
|
#include "tasks_internal.h"
|
2017-02-04 09:20:41 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "../config.h"
|
|
|
|
#endif
|
|
|
|
|
2016-12-02 18:56:29 -05:00
|
|
|
#include "../verbosity.h"
|
|
|
|
#include "../network/netplay/netplay_discovery.h"
|
2017-02-04 09:20:41 +01:00
|
|
|
|
2016-12-02 18:56:29 -05:00
|
|
|
static void task_netplay_lan_scan_handler(retro_task_t *task)
|
|
|
|
{
|
|
|
|
if (init_netplay_discovery())
|
|
|
|
{
|
2016-12-04 19:08:24 +01:00
|
|
|
netplay_discovery_driver_ctl(
|
|
|
|
RARCH_NETPLAY_DISCOVERY_CTL_LAN_CLEAR_RESPONSES, NULL);
|
|
|
|
netplay_discovery_driver_ctl(
|
|
|
|
RARCH_NETPLAY_DISCOVERY_CTL_LAN_SEND_QUERY, NULL);
|
2016-12-02 18:56:29 -05:00
|
|
|
}
|
|
|
|
|
2016-12-29 00:50:18 -05:00
|
|
|
task_set_progress(task, 100);
|
|
|
|
task_set_finished(task, true);
|
2016-12-02 18:56:29 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-15 02:08:59 +02:00
|
|
|
bool task_push_netplay_lan_scan(retro_task_callback_t cb)
|
2016-12-02 18:56:29 -05:00
|
|
|
{
|
2018-11-22 15:45:52 +01:00
|
|
|
retro_task_t *task = task_init();
|
2016-12-02 18:56:29 -05:00
|
|
|
|
|
|
|
if (!task)
|
2016-12-05 07:06:32 +01:00
|
|
|
return false;
|
2016-12-02 18:56:29 -05:00
|
|
|
|
2016-12-04 04:30:43 +01:00
|
|
|
task->type = TASK_TYPE_BLOCKING;
|
|
|
|
task->handler = task_netplay_lan_scan_handler;
|
2017-05-15 02:08:59 +02:00
|
|
|
task->callback = cb;
|
2017-01-23 14:15:26 +01:00
|
|
|
task->title = strdup(msg_hash_to_str(MSG_NETPLAY_LAN_SCANNING));
|
2016-12-02 18:56:29 -05:00
|
|
|
|
2017-05-14 20:43:39 +02:00
|
|
|
task_queue_push(task);
|
2016-12-02 18:56:29 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-02-27 19:00:43 -05:00
|
|
|
|
2017-05-15 02:08:59 +02:00
|
|
|
bool task_push_netplay_lan_scan_rooms(retro_task_callback_t cb)
|
2017-02-27 19:00:43 -05:00
|
|
|
{
|
2018-11-22 15:45:52 +01:00
|
|
|
retro_task_t *task = task_init();
|
2017-02-27 19:00:43 -05:00
|
|
|
|
|
|
|
if (!task)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
task->type = TASK_TYPE_BLOCKING;
|
|
|
|
task->handler = task_netplay_lan_scan_handler;
|
2017-05-15 02:08:59 +02:00
|
|
|
task->callback = cb;
|
2017-02-27 19:00:43 -05:00
|
|
|
task->title = strdup(msg_hash_to_str(MSG_NETPLAY_LAN_SCANNING));
|
|
|
|
|
2017-05-14 20:43:39 +02:00
|
|
|
task_queue_push(task);
|
2017-02-27 19:00:43 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|