1 /**
2 UPNP device.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.upnpdevice;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.reference;
24 /**
25 UPNP device.
26 
27 See $(D UPNP) for UPNP discovery and utility functions. Provides low-level access to UPNP control commands. Allows to manage port mappings (port forwarding) and to query network information of the device (like local and external IP address and status). Note that methods on this class are synchronous and block the calling thread.
28 */
29 @GodotBaseClass struct UPNPDevice
30 {
31 	enum string _GODOT_internal_name = "UPNPDevice";
32 public:
33 @nogc nothrow:
34 	union { godot_object _godot_object; Reference _GODOT_base; }
35 	alias _GODOT_base this;
36 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
37 	package(godot) __gshared bool _classBindingInitialized = false;
38 	package(godot) static struct _classBinding
39 	{
40 		__gshared:
41 		@GodotName("is_valid_gateway") GodotMethod!(bool) isValidGateway;
42 		@GodotName("query_external_address") GodotMethod!(String) queryExternalAddress;
43 		@GodotName("add_port_mapping") GodotMethod!(long, long, long, String, String, long) addPortMapping;
44 		@GodotName("delete_port_mapping") GodotMethod!(long, long, String) deletePortMapping;
45 		@GodotName("set_description_url") GodotMethod!(void, String) setDescriptionUrl;
46 		@GodotName("get_description_url") GodotMethod!(String) getDescriptionUrl;
47 		@GodotName("set_service_type") GodotMethod!(void, String) setServiceType;
48 		@GodotName("get_service_type") GodotMethod!(String) getServiceType;
49 		@GodotName("set_igd_control_url") GodotMethod!(void, String) setIgdControlUrl;
50 		@GodotName("get_igd_control_url") GodotMethod!(String) getIgdControlUrl;
51 		@GodotName("set_igd_service_type") GodotMethod!(void, String) setIgdServiceType;
52 		@GodotName("get_igd_service_type") GodotMethod!(String) getIgdServiceType;
53 		@GodotName("set_igd_our_addr") GodotMethod!(void, String) setIgdOurAddr;
54 		@GodotName("get_igd_our_addr") GodotMethod!(String) getIgdOurAddr;
55 		@GodotName("set_igd_status") GodotMethod!(void, long) setIgdStatus;
56 		@GodotName("get_igd_status") GodotMethod!(UPNPDevice.IGDStatus) getIgdStatus;
57 	}
58 	bool opEquals(in UPNPDevice other) const { return _godot_object.ptr is other._godot_object.ptr; }
59 	UPNPDevice opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
60 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
61 	mixin baseCasts;
62 	static UPNPDevice _new()
63 	{
64 		static godot_class_constructor constructor;
65 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("UPNPDevice");
66 		if(constructor is null) return typeof(this).init;
67 		return cast(UPNPDevice)(constructor());
68 	}
69 	@disable new(size_t s);
70 	/// 
71 	enum IGDStatus : int
72 	{
73 		/**
74 		OK.
75 		*/
76 		igdStatusOk = 0,
77 		/**
78 		HTTP error.
79 		*/
80 		igdStatusHttpError = 1,
81 		/**
82 		Empty HTTP response.
83 		*/
84 		igdStatusHttpEmpty = 2,
85 		/**
86 		Returned response contained no URLs.
87 		*/
88 		igdStatusNoUrls = 3,
89 		/**
90 		Not a valid IGD.
91 		*/
92 		igdStatusNoIgd = 4,
93 		/**
94 		Disconnected.
95 		*/
96 		igdStatusDisconnected = 5,
97 		/**
98 		Unknown device.
99 		*/
100 		igdStatusUnknownDevice = 6,
101 		/**
102 		Invalid control.
103 		*/
104 		igdStatusInvalidControl = 7,
105 		/**
106 		Memory allocation error.
107 		*/
108 		igdStatusMallocError = 8,
109 		/**
110 		Unknown error.
111 		*/
112 		igdStatusUnknownError = 9,
113 	}
114 	/// 
115 	enum Constants : int
116 	{
117 		igdStatusOk = 0,
118 		igdStatusHttpError = 1,
119 		igdStatusHttpEmpty = 2,
120 		igdStatusNoUrls = 3,
121 		igdStatusNoIgd = 4,
122 		igdStatusDisconnected = 5,
123 		igdStatusUnknownDevice = 6,
124 		igdStatusInvalidControl = 7,
125 		igdStatusMallocError = 8,
126 		igdStatusUnknownError = 9,
127 	}
128 	/**
129 	Returns `true` if this is a valid IGD (InternetGatewayDevice) which potentially supports port forwarding.
130 	*/
131 	bool isValidGateway() const
132 	{
133 		checkClassBinding!(typeof(this))();
134 		return ptrcall!(bool)(_classBinding.isValidGateway, _godot_object);
135 	}
136 	/**
137 	Returns the external IP address of this $(D UPNPDevice) or an empty string.
138 	*/
139 	String queryExternalAddress() const
140 	{
141 		checkClassBinding!(typeof(this))();
142 		return ptrcall!(String)(_classBinding.queryExternalAddress, _godot_object);
143 	}
144 	/**
145 	Adds a port mapping to forward the given external port on this $(D UPNPDevice) for the given protocol to the local machine. See $(D UPNP.addPortMapping).
146 	*/
147 	long addPortMapping(StringArg2, StringArg3)(in long port, in long port_internal = 0, in StringArg2 desc = "", in StringArg3 proto = "UDP", in long duration = 0) const
148 	{
149 		checkClassBinding!(typeof(this))();
150 		return ptrcall!(long)(_classBinding.addPortMapping, _godot_object, port, port_internal, desc, proto, duration);
151 	}
152 	/**
153 	Deletes the port mapping identified by the given port and protocol combination on this device. See $(D UPNP.deletePortMapping).
154 	*/
155 	long deletePortMapping(StringArg1)(in long port, in StringArg1 proto = "UDP") const
156 	{
157 		checkClassBinding!(typeof(this))();
158 		return ptrcall!(long)(_classBinding.deletePortMapping, _godot_object, port, proto);
159 	}
160 	/**
161 	
162 	*/
163 	void setDescriptionUrl(StringArg0)(in StringArg0 url)
164 	{
165 		checkClassBinding!(typeof(this))();
166 		ptrcall!(void)(_classBinding.setDescriptionUrl, _godot_object, url);
167 	}
168 	/**
169 	
170 	*/
171 	String getDescriptionUrl() const
172 	{
173 		checkClassBinding!(typeof(this))();
174 		return ptrcall!(String)(_classBinding.getDescriptionUrl, _godot_object);
175 	}
176 	/**
177 	
178 	*/
179 	void setServiceType(StringArg0)(in StringArg0 type)
180 	{
181 		checkClassBinding!(typeof(this))();
182 		ptrcall!(void)(_classBinding.setServiceType, _godot_object, type);
183 	}
184 	/**
185 	
186 	*/
187 	String getServiceType() const
188 	{
189 		checkClassBinding!(typeof(this))();
190 		return ptrcall!(String)(_classBinding.getServiceType, _godot_object);
191 	}
192 	/**
193 	
194 	*/
195 	void setIgdControlUrl(StringArg0)(in StringArg0 url)
196 	{
197 		checkClassBinding!(typeof(this))();
198 		ptrcall!(void)(_classBinding.setIgdControlUrl, _godot_object, url);
199 	}
200 	/**
201 	
202 	*/
203 	String getIgdControlUrl() const
204 	{
205 		checkClassBinding!(typeof(this))();
206 		return ptrcall!(String)(_classBinding.getIgdControlUrl, _godot_object);
207 	}
208 	/**
209 	
210 	*/
211 	void setIgdServiceType(StringArg0)(in StringArg0 type)
212 	{
213 		checkClassBinding!(typeof(this))();
214 		ptrcall!(void)(_classBinding.setIgdServiceType, _godot_object, type);
215 	}
216 	/**
217 	
218 	*/
219 	String getIgdServiceType() const
220 	{
221 		checkClassBinding!(typeof(this))();
222 		return ptrcall!(String)(_classBinding.getIgdServiceType, _godot_object);
223 	}
224 	/**
225 	
226 	*/
227 	void setIgdOurAddr(StringArg0)(in StringArg0 addr)
228 	{
229 		checkClassBinding!(typeof(this))();
230 		ptrcall!(void)(_classBinding.setIgdOurAddr, _godot_object, addr);
231 	}
232 	/**
233 	
234 	*/
235 	String getIgdOurAddr() const
236 	{
237 		checkClassBinding!(typeof(this))();
238 		return ptrcall!(String)(_classBinding.getIgdOurAddr, _godot_object);
239 	}
240 	/**
241 	
242 	*/
243 	void setIgdStatus(in long status)
244 	{
245 		checkClassBinding!(typeof(this))();
246 		ptrcall!(void)(_classBinding.setIgdStatus, _godot_object, status);
247 	}
248 	/**
249 	
250 	*/
251 	UPNPDevice.IGDStatus getIgdStatus() const
252 	{
253 		checkClassBinding!(typeof(this))();
254 		return ptrcall!(UPNPDevice.IGDStatus)(_classBinding.getIgdStatus, _godot_object);
255 	}
256 	/**
257 	URL to the device description.
258 	*/
259 	@property String descriptionUrl()
260 	{
261 		return getDescriptionUrl();
262 	}
263 	/// ditto
264 	@property void descriptionUrl(String v)
265 	{
266 		setDescriptionUrl(v);
267 	}
268 	/**
269 	Service type.
270 	*/
271 	@property String serviceType()
272 	{
273 		return getServiceType();
274 	}
275 	/// ditto
276 	@property void serviceType(String v)
277 	{
278 		setServiceType(v);
279 	}
280 	/**
281 	IDG control URL.
282 	*/
283 	@property String igdControlUrl()
284 	{
285 		return getIgdControlUrl();
286 	}
287 	/// ditto
288 	@property void igdControlUrl(String v)
289 	{
290 		setIgdControlUrl(v);
291 	}
292 	/**
293 	IGD service type.
294 	*/
295 	@property String igdServiceType()
296 	{
297 		return getIgdServiceType();
298 	}
299 	/// ditto
300 	@property void igdServiceType(String v)
301 	{
302 		setIgdServiceType(v);
303 	}
304 	/**
305 	Address of the local machine in the network connecting it to this $(D UPNPDevice).
306 	*/
307 	@property String igdOurAddr()
308 	{
309 		return getIgdOurAddr();
310 	}
311 	/// ditto
312 	@property void igdOurAddr(String v)
313 	{
314 		setIgdOurAddr(v);
315 	}
316 	/**
317 	IGD status. See $(D igdstatus).
318 	*/
319 	@property UPNPDevice.IGDStatus igdStatus()
320 	{
321 		return getIgdStatus();
322 	}
323 	/// ditto
324 	@property void igdStatus(long v)
325 	{
326 		setIgdStatus(v);
327 	}
328 }