1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GSrvTarget.html
27  * outPack = gio
28  * outFile = SrvTarget
29  * strct   = GSrvTarget
30  * realStrct=
31  * ctorStrct=
32  * clss    = SrvTarget
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_srv_target_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ListG
48  * structWrap:
49  * 	- GList* -> ListG
50  * 	- GSrvTarget* -> SrvTarget
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gio.SrvTarget;
57 
58 public  import gtkc.giotypes;
59 
60 private import gtkc.gio;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 
65 private import glib.Str;
66 private import glib.ListG;
67 
68 
69 
70 private import gobject.Boxed;
71 
72 /**
73  * Description
74  * SRV (service) records are used by some network protocols to provide
75  * service-specific aliasing and load-balancing. For example, XMPP
76  * (Jabber) uses SRV records to locate the XMPP server for a domain;
77  * rather than connecting directly to "example.com" or assuming a
78  * specific server hostname like "xmpp.example.com", an XMPP client
79  * would look up the "xmpp-client" SRV record for "example.com", and
80  * then connect to whatever host was pointed to by that record.
81  * You can use g_resolver_lookup_service() or
82  * g_resolver_lookup_service_async() to find the GSrvTargets
83  * for a given service. However, if you are simply planning to connect
84  * to the remote service, you can use GNetworkService's
85  * GSocketConnectable interface and not need to worry about
86  * GSrvTarget at all.
87  */
88 public class SrvTarget : Boxed
89 {
90 	
91 	/** the main Gtk struct */
92 	protected GSrvTarget* gSrvTarget;
93 	
94 	
95 	public GSrvTarget* getSrvTargetStruct()
96 	{
97 		return gSrvTarget;
98 	}
99 	
100 	
101 	/** the main Gtk struct as a void* */
102 	protected void* getStruct()
103 	{
104 		return cast(void*)gSrvTarget;
105 	}
106 	
107 	/**
108 	 * Sets our main struct and passes it to the parent class
109 	 */
110 	public this (GSrvTarget* gSrvTarget)
111 	{
112 		this.gSrvTarget = gSrvTarget;
113 	}
114 	
115 	/**
116 	 */
117 	
118 	/**
119 	 * Creates a new GSrvTarget with the given parameters.
120 	 * You should not need to use this; normally GSrvTargets are
121 	 * created by GResolver.
122 	 * Since 2.22
123 	 * Params:
124 	 * hostname = the host that the service is running on
125 	 * port = the port that the service is running on
126 	 * priority = the target's priority
127 	 * weight = the target's weight
128 	 * Throws: ConstructionException GTK+ fails to create the object.
129 	 */
130 	public this (string hostname, ushort port, ushort priority, ushort weight)
131 	{
132 		// GSrvTarget * g_srv_target_new (const gchar *hostname,  guint16 port,  guint16 priority,  guint16 weight);
133 		auto p = g_srv_target_new(Str.toStringz(hostname), port, priority, weight);
134 		if(p is null)
135 		{
136 			throw new ConstructionException("null returned by g_srv_target_new(Str.toStringz(hostname), port, priority, weight)");
137 		}
138 		this(cast(GSrvTarget*) p);
139 	}
140 	
141 	/**
142 	 * Copies target
143 	 * Since 2.22
144 	 * Returns: a copy of target
145 	 */
146 	public SrvTarget copy()
147 	{
148 		// GSrvTarget * g_srv_target_copy (GSrvTarget *target);
149 		auto p = g_srv_target_copy(gSrvTarget);
150 		
151 		if(p is null)
152 		{
153 			return null;
154 		}
155 		
156 		return ObjectG.getDObject!(SrvTarget)(cast(GSrvTarget*) p);
157 	}
158 	
159 	/**
160 	 * Frees target
161 	 * Since 2.22
162 	 */
163 	public void free()
164 	{
165 		// void g_srv_target_free (GSrvTarget *target);
166 		g_srv_target_free(gSrvTarget);
167 	}
168 	
169 	/**
170 	 * Gets target's hostname (in ASCII form; if you are going to present
171 	 * this to the user, you should use g_hostname_is_ascii_encoded() to
172 	 * check if it contains encoded Unicode segments, and use
173 	 * g_hostname_to_unicode() to convert it if it does.)
174 	 * Since 2.22
175 	 * Returns: target's hostname
176 	 */
177 	public string getHostname()
178 	{
179 		// const gchar * g_srv_target_get_hostname (GSrvTarget *target);
180 		return Str.toString(g_srv_target_get_hostname(gSrvTarget));
181 	}
182 	
183 	/**
184 	 * Gets target's port
185 	 * Since 2.22
186 	 * Returns: target's port
187 	 */
188 	public ushort getPort()
189 	{
190 		// guint16 g_srv_target_get_port (GSrvTarget *target);
191 		return g_srv_target_get_port(gSrvTarget);
192 	}
193 	
194 	/**
195 	 * Gets target's priority. You should not need to look at this;
196 	 * GResolver already sorts the targets according to the algorithm in
197 	 * RFC 2782.
198 	 * Since 2.22
199 	 * Returns: target's priority
200 	 */
201 	public ushort getPriority()
202 	{
203 		// guint16 g_srv_target_get_priority (GSrvTarget *target);
204 		return g_srv_target_get_priority(gSrvTarget);
205 	}
206 	
207 	/**
208 	 * Gets target's weight. You should not need to look at this;
209 	 * GResolver already sorts the targets according to the algorithm in
210 	 * RFC 2782.
211 	 * Since 2.22
212 	 * Returns: target's weight
213 	 */
214 	public ushort getWeight()
215 	{
216 		// guint16 g_srv_target_get_weight (GSrvTarget *target);
217 		return g_srv_target_get_weight(gSrvTarget);
218 	}
219 	
220 	/**
221 	 * Sorts targets in place according to the algorithm in RFC 2782.
222 	 * Since 2.22
223 	 * Params:
224 	 * targets = a GList of GSrvTarget
225 	 * Returns: the head of the sorted list. [transfer full]
226 	 */
227 	public static ListG listSort(ListG targets)
228 	{
229 		// GList * g_srv_target_list_sort (GList *targets);
230 		auto p = g_srv_target_list_sort((targets is null) ? null : targets.getListGStruct());
231 		
232 		if(p is null)
233 		{
234 			return null;
235 		}
236 		
237 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
238 	}
239 }