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