| 1 | /**************************************************************************/ |
| 2 | /* upnp_device.cpp */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #include "upnp_device.h" |
| 32 | |
| 33 | UPNPDevice *(*UPNPDevice::_create)(bool p_notify_postinitialize) = nullptr; |
| 34 | |
| 35 | void UPNPDevice::_bind_methods() { |
| 36 | ClassDB::bind_method(D_METHOD("is_valid_gateway"), &UPNPDevice::is_valid_gateway); |
| 37 | ClassDB::bind_method(D_METHOD("query_external_address"), &UPNPDevice::query_external_address); |
| 38 | ClassDB::bind_method(D_METHOD("add_port_mapping", "port", "port_internal", "desc", "proto", "duration"), &UPNPDevice::add_port_mapping, DEFVAL(0), DEFVAL(""), DEFVAL("UDP"), DEFVAL(0)); |
| 39 | ClassDB::bind_method(D_METHOD("delete_port_mapping", "port", "proto"), &UPNPDevice::delete_port_mapping, DEFVAL("UDP")); |
| 40 | |
| 41 | ClassDB::bind_method(D_METHOD("set_description_url", "url"), &UPNPDevice::set_description_url); |
| 42 | ClassDB::bind_method(D_METHOD("get_description_url"), &UPNPDevice::get_description_url); |
| 43 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "description_url"), "set_description_url", "get_description_url"); |
| 44 | |
| 45 | ClassDB::bind_method(D_METHOD("set_service_type", "type"), &UPNPDevice::set_service_type); |
| 46 | ClassDB::bind_method(D_METHOD("get_service_type"), &UPNPDevice::get_service_type); |
| 47 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "service_type"), "set_service_type", "get_service_type"); |
| 48 | |
| 49 | ClassDB::bind_method(D_METHOD("set_igd_control_url", "url"), &UPNPDevice::set_igd_control_url); |
| 50 | ClassDB::bind_method(D_METHOD("get_igd_control_url"), &UPNPDevice::get_igd_control_url); |
| 51 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "igd_control_url"), "set_igd_control_url", "get_igd_control_url"); |
| 52 | |
| 53 | ClassDB::bind_method(D_METHOD("set_igd_service_type", "type"), &UPNPDevice::set_igd_service_type); |
| 54 | ClassDB::bind_method(D_METHOD("get_igd_service_type"), &UPNPDevice::get_igd_service_type); |
| 55 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "igd_service_type"), "set_igd_service_type", "get_igd_service_type"); |
| 56 | |
| 57 | ClassDB::bind_method(D_METHOD("set_igd_our_addr", "addr"), &UPNPDevice::set_igd_our_addr); |
| 58 | ClassDB::bind_method(D_METHOD("get_igd_our_addr"), &UPNPDevice::get_igd_our_addr); |
| 59 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "igd_our_addr"), "set_igd_our_addr", "get_igd_our_addr"); |
| 60 | |
| 61 | ClassDB::bind_method(D_METHOD("set_igd_status", "status"), &UPNPDevice::set_igd_status); |
| 62 | ClassDB::bind_method(D_METHOD("get_igd_status"), &UPNPDevice::get_igd_status); |
| 63 | ADD_PROPERTY(PropertyInfo(Variant::INT, "igd_status", PROPERTY_HINT_ENUM), "set_igd_status", "get_igd_status"); |
| 64 | |
| 65 | BIND_ENUM_CONSTANT(IGD_STATUS_OK); |
| 66 | BIND_ENUM_CONSTANT(IGD_STATUS_HTTP_ERROR); |
| 67 | BIND_ENUM_CONSTANT(IGD_STATUS_HTTP_EMPTY); |
| 68 | BIND_ENUM_CONSTANT(IGD_STATUS_NO_URLS); |
| 69 | BIND_ENUM_CONSTANT(IGD_STATUS_NO_IGD); |
| 70 | BIND_ENUM_CONSTANT(IGD_STATUS_DISCONNECTED); |
| 71 | BIND_ENUM_CONSTANT(IGD_STATUS_UNKNOWN_DEVICE); |
| 72 | BIND_ENUM_CONSTANT(IGD_STATUS_INVALID_CONTROL); |
| 73 | BIND_ENUM_CONSTANT(IGD_STATUS_MALLOC_ERROR); |
| 74 | BIND_ENUM_CONSTANT(IGD_STATUS_UNKNOWN_ERROR); |
| 75 | } |