upnp_device.cpp 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include "upnp_device.h"
  31. UPNPDevice *(*UPNPDevice::_create)(bool p_notify_postinitialize) = nullptr;
  32. void UPNPDevice::_bind_methods() {
  33. ClassDB::bind_method(D_METHOD("is_valid_gateway"), &UPNPDevice::is_valid_gateway);
  34. ClassDB::bind_method(D_METHOD("query_external_address"), &UPNPDevice::query_external_address);
  35. 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));
  36. ClassDB::bind_method(D_METHOD("delete_port_mapping", "port", "proto"), &UPNPDevice::delete_port_mapping, DEFVAL("UDP"));
  37. ClassDB::bind_method(D_METHOD("set_description_url", "url"), &UPNPDevice::set_description_url);
  38. ClassDB::bind_method(D_METHOD("get_description_url"), &UPNPDevice::get_description_url);
  39. ADD_PROPERTY(PropertyInfo(Variant::STRING, "description_url"), "set_description_url", "get_description_url");
  40. ClassDB::bind_method(D_METHOD("set_service_type", "type"), &UPNPDevice::set_service_type);
  41. ClassDB::bind_method(D_METHOD("get_service_type"), &UPNPDevice::get_service_type);
  42. ADD_PROPERTY(PropertyInfo(Variant::STRING, "service_type"), "set_service_type", "get_service_type");
  43. ClassDB::bind_method(D_METHOD("set_igd_control_url", "url"), &UPNPDevice::set_igd_control_url);
  44. ClassDB::bind_method(D_METHOD("get_igd_control_url"), &UPNPDevice::get_igd_control_url);
  45. ADD_PROPERTY(PropertyInfo(Variant::STRING, "igd_control_url"), "set_igd_control_url", "get_igd_control_url");
  46. ClassDB::bind_method(D_METHOD("set_igd_service_type", "type"), &UPNPDevice::set_igd_service_type);
  47. ClassDB::bind_method(D_METHOD("get_igd_service_type"), &UPNPDevice::get_igd_service_type);
  48. ADD_PROPERTY(PropertyInfo(Variant::STRING, "igd_service_type"), "set_igd_service_type", "get_igd_service_type");
  49. ClassDB::bind_method(D_METHOD("set_igd_our_addr", "addr"), &UPNPDevice::set_igd_our_addr);
  50. ClassDB::bind_method(D_METHOD("get_igd_our_addr"), &UPNPDevice::get_igd_our_addr);
  51. ADD_PROPERTY(PropertyInfo(Variant::STRING, "igd_our_addr"), "set_igd_our_addr", "get_igd_our_addr");
  52. ClassDB::bind_method(D_METHOD("set_igd_status", "status"), &UPNPDevice::set_igd_status);
  53. ClassDB::bind_method(D_METHOD("get_igd_status"), &UPNPDevice::get_igd_status);
  54. ADD_PROPERTY(PropertyInfo(Variant::INT, "igd_status", PROPERTY_HINT_ENUM), "set_igd_status", "get_igd_status");
  55. BIND_ENUM_CONSTANT(IGD_STATUS_OK);
  56. BIND_ENUM_CONSTANT(IGD_STATUS_HTTP_ERROR);
  57. BIND_ENUM_CONSTANT(IGD_STATUS_HTTP_EMPTY);
  58. BIND_ENUM_CONSTANT(IGD_STATUS_NO_URLS);
  59. BIND_ENUM_CONSTANT(IGD_STATUS_NO_IGD);
  60. BIND_ENUM_CONSTANT(IGD_STATUS_DISCONNECTED);
  61. BIND_ENUM_CONSTANT(IGD_STATUS_UNKNOWN_DEVICE);
  62. BIND_ENUM_CONSTANT(IGD_STATUS_INVALID_CONTROL);
  63. BIND_ENUM_CONSTANT(IGD_STATUS_MALLOC_ERROR);
  64. BIND_ENUM_CONSTANT(IGD_STATUS_UNKNOWN_ERROR);
  65. }