RetroArch/tasks/task_netplay_lan_scan.c

80 lines
2.1 KiB
C
Raw Normal View History

/* RetroArch - A frontend for libretro.
2017-01-22 13:40:32 +01:00
* Copyright (C) 2016-2017 - Jean-André Santoni
* Copyright (C) 2017 - Andrés Suárez
*
* 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>
#include <string/stdstring.h>
#include "../paths.h"
#include "task_file_transfer.h"
#include "tasks_internal.h"
2017-02-04 09:20:41 +01:00
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#include "../verbosity.h"
#include "../network/netplay/netplay_discovery.h"
2017-02-04 09:20:41 +01:00
static void task_netplay_lan_scan_handler(retro_task_t *task)
{
if (init_netplay_discovery())
{
netplay_discovery_driver_ctl(
RARCH_NETPLAY_DISCOVERY_CTL_LAN_CLEAR_RESPONSES, NULL);
netplay_discovery_driver_ctl(
RARCH_NETPLAY_DISCOVERY_CTL_LAN_SEND_QUERY, NULL);
}
task_set_progress(task, 100);
task_set_finished(task, true);
return;
}
bool task_push_netplay_lan_scan(retro_task_callback_t cb)
{
retro_task_t *task = task_init();
if (!task)
2016-12-05 07:06:32 +01:00
return false;
2016-12-04 04:30:43 +01:00
task->type = TASK_TYPE_BLOCKING;
task->handler = task_netplay_lan_scan_handler;
task->callback = cb;
task->title = strdup(msg_hash_to_str(MSG_NETPLAY_LAN_SCANNING));
2017-05-14 20:43:39 +02:00
task_queue_push(task);
return true;
}
2017-02-27 19:00:43 -05:00
bool task_push_netplay_lan_scan_rooms(retro_task_callback_t cb)
2017-02-27 19:00:43 -05: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;
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;
}