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 module gio.SrvTarget; 26 27 private import glib.ConstructionException; 28 private import glib.ListG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gtkc.gio; 32 public import gtkc.giotypes; 33 34 35 /** 36 * SRV (service) records are used by some network protocols to provide 37 * service-specific aliasing and load-balancing. For example, XMPP 38 * (Jabber) uses SRV records to locate the XMPP server for a domain; 39 * rather than connecting directly to "example.com" or assuming a 40 * specific server hostname like "xmpp.example.com", an XMPP client 41 * would look up the "xmpp-client" SRV record for "example.com", and 42 * then connect to whatever host was pointed to by that record. 43 * 44 * You can use g_resolver_lookup_service() or 45 * g_resolver_lookup_service_async() to find the #GSrvTargets 46 * for a given service. However, if you are simply planning to connect 47 * to the remote service, you can use #GNetworkService's 48 * #GSocketConnectable interface and not need to worry about 49 * #GSrvTarget at all. 50 */ 51 public class SrvTarget 52 { 53 /** the main Gtk struct */ 54 protected GSrvTarget* gSrvTarget; 55 56 /** Get the main Gtk struct */ 57 public GSrvTarget* getSrvTargetStruct() 58 { 59 return gSrvTarget; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected void* getStruct() 64 { 65 return cast(void*)gSrvTarget; 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GSrvTarget* gSrvTarget) 72 { 73 this.gSrvTarget = gSrvTarget; 74 } 75 76 77 /** */ 78 public static GType getType() 79 { 80 return g_srv_target_get_type(); 81 } 82 83 /** 84 * Creates a new #GSrvTarget with the given parameters. 85 * 86 * You should not need to use this; normally #GSrvTargets are 87 * created by #GResolver. 88 * 89 * Params: 90 * hostname = the host that the service is running on 91 * port = the port that the service is running on 92 * priority = the target's priority 93 * weight = the target's weight 94 * 95 * Return: a new #GSrvTarget. 96 * 97 * Since: 2.22 98 * 99 * Throws: ConstructionException GTK+ fails to create the object. 100 */ 101 public this(string hostname, ushort port, ushort priority, ushort weight) 102 { 103 auto p = g_srv_target_new(Str.toStringz(hostname), port, priority, weight); 104 105 if(p is null) 106 { 107 throw new ConstructionException("null returned by new"); 108 } 109 110 this(cast(GSrvTarget*) p); 111 } 112 113 /** 114 * Copies @target 115 * 116 * Return: a copy of @target 117 * 118 * Since: 2.22 119 */ 120 public SrvTarget copy() 121 { 122 auto p = g_srv_target_copy(gSrvTarget); 123 124 if(p is null) 125 { 126 return null; 127 } 128 129 return ObjectG.getDObject!(SrvTarget)(cast(GSrvTarget*) p); 130 } 131 132 /** 133 * Frees @target 134 * 135 * Since: 2.22 136 */ 137 public void free() 138 { 139 g_srv_target_free(gSrvTarget); 140 } 141 142 /** 143 * Gets @target's hostname (in ASCII form; if you are going to present 144 * this to the user, you should use g_hostname_is_ascii_encoded() to 145 * check if it contains encoded Unicode segments, and use 146 * g_hostname_to_unicode() to convert it if it does.) 147 * 148 * Return: @target's hostname 149 * 150 * Since: 2.22 151 */ 152 public string getHostname() 153 { 154 return Str.toString(g_srv_target_get_hostname(gSrvTarget)); 155 } 156 157 /** 158 * Gets @target's port 159 * 160 * Return: @target's port 161 * 162 * Since: 2.22 163 */ 164 public ushort getPort() 165 { 166 return g_srv_target_get_port(gSrvTarget); 167 } 168 169 /** 170 * Gets @target's priority. You should not need to look at this; 171 * #GResolver already sorts the targets according to the algorithm in 172 * RFC 2782. 173 * 174 * Return: @target's priority 175 * 176 * Since: 2.22 177 */ 178 public ushort getPriority() 179 { 180 return g_srv_target_get_priority(gSrvTarget); 181 } 182 183 /** 184 * Gets @target's weight. You should not need to look at this; 185 * #GResolver already sorts the targets according to the algorithm in 186 * RFC 2782. 187 * 188 * Return: @target's weight 189 * 190 * Since: 2.22 191 */ 192 public ushort getWeight() 193 { 194 return g_srv_target_get_weight(gSrvTarget); 195 } 196 197 /** 198 * Sorts @targets in place according to the algorithm in RFC 2782. 199 * 200 * Params: 201 * targets = a #GList of #GSrvTarget 202 * 203 * Return: the head of the sorted list. 204 * 205 * Since: 2.22 206 */ 207 public static ListG listSort(ListG targets) 208 { 209 auto p = g_srv_target_list_sort((targets is null) ? null : targets.getListGStruct()); 210 211 if(p is null) 212 { 213 return null; 214 } 215 216 return new ListG(cast(GList*) p); 217 } 218 }